Class: LensProtocol::OMA::Types::Type
- Inherits:
-
Object
- Object
- LensProtocol::OMA::Types::Type
- Defined in:
- lib/lens_protocol/oma/types/type.rb
Instance Method Summary collapse
-
#format(_label, _value) ⇒ Object
Receives a record label and value.
-
#initialize(value_type: :string, decimals: nil) ⇒ Type
constructor
A new instance of Type.
-
#parse(_line, _next_lines) ⇒ Object
Receives the current line and the lines after that.
-
#wrap(value, _message_hash, _label) ⇒ Object
Used when building a message from a hash.
Constructor Details
#initialize(value_type: :string, decimals: nil) ⇒ Type
Returns a new instance of Type.
5 6 7 8 |
# File 'lib/lens_protocol/oma/types/type.rb', line 5 def initialize value_type: :string, decimals: nil @value_type = value_type @decimals = decimals end |
Instance Method Details
#format(_label, _value) ⇒ Object
Receives a record label and value. Must return one line or and array of them.
25 26 27 |
# File 'lib/lens_protocol/oma/types/type.rb', line 25 def format _label, _value raise NotImplementedError, self end |
#parse(_line, _next_lines) ⇒ Object
Receives the current line and the lines after that. Must return the parsed value to store on the message, and the array of (possibly filtered) next lines.
12 13 14 |
# File 'lib/lens_protocol/oma/types/type.rb', line 12 def parse _line, _next_lines raise NotImplementedError, self end |
#wrap(value, _message_hash, _label) ⇒ Object
Used when building a message from a hash. Validations may be placed in the subclasses. TODO The message hash is only used for records like TRCFMT that need to access the R values, but having the R at the same level in the hash would not allow for building messages with TRCFMT and STHKFMT.
19 20 21 |
# File 'lib/lens_protocol/oma/types/type.rb', line 19 def wrap value, , _label value end |