Class: Senec::Local::Value
- Inherits:
-
Object
- Object
- Senec::Local::Value
- Defined in:
- lib/senec/local/value.rb
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #decoded ⇒ Object (also: #to_i, #to_f, #to_s)
-
#initialize(raw) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(raw) ⇒ Value
Returns a new instance of Value.
4 5 6 7 |
# File 'lib/senec/local/value.rb', line 4 def initialize(raw) @raw = raw @prefix, @value = raw&.split('_') end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
9 10 11 |
# File 'lib/senec/local/value.rb', line 9 def prefix @prefix end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
9 10 11 |
# File 'lib/senec/local/value.rb', line 9 def raw @raw end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/senec/local/value.rb', line 9 def value @value end |
Instance Method Details
#decoded ⇒ Object Also known as: to_i, to_f, to_s
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/senec/local/value.rb', line 11 def decoded case prefix when 'fl' decoded_float(value) when 'i3', 'u1', 'u3', 'u6', 'u8' decoded_int(value) when 'st' value # TODO: There are some more prefixes to handle else raise DecodingError, "Unknown value '#{@raw}'" end end |