Class: LensProtocol::OMA::Types::Single

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

Instance Method Summary collapse

Methods inherited from Type

#initialize

Constructor Details

This class inherits a constructor from LensProtocol::OMA::Types::Type

Instance Method Details

#format(label, value) ⇒ Object



15
16
17
# File 'lib/lens_protocol/oma/types/single.rb', line 15

def format label, value
  build_line label, format_value(value)
end

#parse(line, next_lines) ⇒ Object



5
6
7
8
# File 'lib/lens_protocol/oma/types/single.rb', line 5

def parse line, next_lines
  value = parse_value line.data
  [value, next_lines]
end

#wrap(value, _message_hash, label) ⇒ Object

Raises:



10
11
12
13
# File 'lib/lens_protocol/oma/types/single.rb', line 10

def wrap value, _message_hash, label
  raise ValidationError, "#{label}: Expected a single value. Got #{value}" if value.respond_to?(:each)
  value
end