Class: LensProtocol::OMA::Types::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/lens_protocol/oma/types/type.rb

Direct Known Subclasses

Array, Chiral, Ignored, Matrix, Single, Trcfmt

Instance Method Summary collapse

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.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


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, _message_hash, _label
  value
end