Class: Modbus::WordRegister
- Defined in:
- lib/modbus/register/word_register.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Register
Instance Method Summary collapse
-
#initialize(addr) ⇒ WordRegister
constructor
A new instance of WordRegister.
- #update(value) ⇒ Object
- #write(value) ⇒ Object
Constructor Details
#initialize(addr) ⇒ WordRegister
Returns a new instance of WordRegister.
12 13 14 15 |
# File 'lib/modbus/register/word_register.rb', line 12 def initialize(addr) super @value = 0 end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/modbus/register/word_register.rb', line 9 def value @value end |
Instance Method Details
#update(value) ⇒ Object
18 19 20 21 |
# File 'lib/modbus/register/word_register.rb', line 18 def update(value) fail ArgumentError unless (0..65535).include? value @value = value end |
#write(value) ⇒ Object
24 25 26 |
# File 'lib/modbus/register/word_register.rb', line 24 def write(value) @handler.write_values [{:addr => @addr.to_s, :value => value}] if @handler end |