plc_access 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7944febc355a406f20d64952237fb1cb58d718c079d9b1743535ce495d5a153
4
- data.tar.gz: d76735035b4e7749ef4beb234b5cad4392090fe892ae6321a3ae24e14a54cc25
3
+ metadata.gz: 64e62d7a3897342a72e3a3e93a95eabf0df0b4362d81454cf5d86842dc74a754
4
+ data.tar.gz: 890d303add93fe36f6f77ac48db506d4105e5379a883c491814bb97eb0691d8c
5
5
  SHA512:
6
- metadata.gz: a8a256b8f7e4cf5d3a7e1cbf6d7d21168ceaccb0927279c1427f293bb603622b648ae1d660649262d10204f8146f926d9f7ec6cf8ec38a2ae6089c475b0f4d39
7
- data.tar.gz: 7d5e7fc1ca634bb9397f4f752b91efa4eecdc3535db7915e01f3e3a0f9b06b57ec250f8d69c4eafba5afbc313d30d17b2f1db629eaef66b15348dbf3da9ea6fa
6
+ metadata.gz: e9ad8b4663e0980bfe8c10e37fc4a8221934e6d612c738ed2a3fe5c1a43492db3dc99371e5f75c399442d89255f6282ae6aaddd7a967a6bc7858cbe76f0b2efb
7
+ data.tar.gz: 05511e4e58e042681e64b5f69a98f04eed22d2738e96c217032a5b92c9cada9078aa87eeaa046639a15553ca3fc8434f673de35774aa73a6ae631427cbbb7293
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plc_access (0.2.1)
4
+ plc_access (0.2.3)
5
5
  serialport (~> 1.3, >= 1.3.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- json (2.18.1)
11
+ json (2.21.2)
12
12
  language_server-protocol (3.17.0.4)
13
13
  lint_roller (1.1.0)
14
14
  parallel (1.26.3)
@@ -30,6 +30,7 @@ module PlcAccess
30
30
  def initialize(a, b = nil)
31
31
  super
32
32
  @suffix = 'R' if @suffix.nil? || @suffix.length.zero?
33
+ raise ArgumentError, "Invalid device suffix: #{@suffix}" unless ESC_SUFFIXES.include?(@suffix)
33
34
  end
34
35
 
35
36
  def +(other)
@@ -46,6 +47,7 @@ module PlcAccess
46
47
  SUFFIXES_FOR_DEC_HEX = %w[R MR LR CR].freeze
47
48
  SUFFIXES_FOR_HEX = %w[B VB W].freeze
48
49
  SUFFIXES_FOR_BIT = %w[R B MR LR CR VB].freeze
50
+ ESC_SUFFIXES = (SUFFIXES_FOR_DEC + SUFFIXES_FOR_DEC_HEX + SUFFIXES_FOR_HEX + SUFFIXES_FOR_BIT).uniq.freeze
49
51
 
50
52
  def suffixes_for_dec
51
53
  SUFFIXES_FOR_DEC
@@ -57,6 +57,7 @@ module PlcAccess
57
57
  @number = ::Regexp.last_match(2).to_i(p_adic_number)
58
58
  end
59
59
  end
60
+ raise ArgumentError, "Invalid device suffix: #{@suffix}" if @suffix && !SUFFIXES.include?(@suffix)
60
61
  end
61
62
 
62
63
  def valid?
@@ -52,6 +52,7 @@ module PlcAccess
52
52
  @bit = ::Regexp.last_match(4).to_i if ::Regexp.last_match(4)
53
53
  end
54
54
  end
55
+ raise ArgumentError, "Invalid device suffix: #{@suffix}" if @suffix && !SUFFIXES.include?(@suffix)
55
56
  case @suffix
56
57
  when 'T', 'C'
57
58
  raise "#{name} is not allowed as a bit device." if @bit
@@ -53,7 +53,7 @@ module PlcAccess
53
53
  @value = 0
54
54
  case a
55
55
  when Integer
56
- @suffix = ESC_SUFFIXES[a]
56
+ @suffix = self.class::ESC_SUFFIXES[a]
57
57
  @number = b
58
58
  when String, Symbol
59
59
  a = a.to_s # convert to string if it's a symbol
@@ -181,7 +181,7 @@ module PlcAccess
181
181
  end
182
182
 
183
183
  def device_code
184
- ESC_SUFFIXES.index @suffix
184
+ self.class::ESC_SUFFIXES.index @suffix
185
185
  end
186
186
 
187
187
  def reset
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlcAccess
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.3'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plc_access
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuyoshi Ito
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-02-14 00:00:00.000000000 Z
10
+ date: 2026-08-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: serialport