Module: Lutaml::Lml::DataProcessor::ValueProcessing

Included in:
Lutaml::Lml::DataProcessor
Defined in:
lib/lutaml/lml/data_processor/value_processing.rb

Constant Summary collapse

VALUE_TYPE_KEYS =
%i[instance list string boolean key_value_map number float condition require].freeze
VALUE_TYPE_HANDLERS =
{
  instance: :handle_instance_value,
  list: :handle_list_value,
  string: :handle_string_value,
  boolean: :handle_boolean_value,
  key_value_map: :handle_key_value_map,
  number: :handle_number_value,
  float: :handle_float_value,
  condition: :handle_delegate_value,
  require: :handle_delegate_value
}.freeze

Instance Method Summary collapse

Instance Method Details

#handle_boolean_value(_key, value) ⇒ Object



49
50
51
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 49

def handle_boolean_value(_key, value)
  ['Boolean', value[:boolean] == 'true']
end

#handle_delegate_value(key, value) ⇒ Object



65
66
67
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 65

def handle_delegate_value(key, value)
  process_value(value[key])
end

#handle_float_value(_key, value) ⇒ Object



61
62
63
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 61

def handle_float_value(_key, value)
  ['Float', value[:float].to_f]
end

#handle_instance_value(_key, value) ⇒ Object



37
38
39
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 37

def handle_instance_value(_key, value)
  ['Instance', process_instance(value[:instance])]
end

#handle_key_value_map(_key, value) ⇒ Object



53
54
55
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 53

def handle_key_value_map(_key, value)
  process_key_value_map(value[:key_value_map])
end

#handle_list_value(_key, value) ⇒ Object



41
42
43
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 41

def handle_list_value(_key, value)
  process_typed_sequence(value[:list])
end

#handle_number_value(_key, value) ⇒ Object



57
58
59
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 57

def handle_number_value(_key, value)
  ['Number', value[:number].to_i]
end

#handle_string_value(_key, value) ⇒ Object



45
46
47
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 45

def handle_string_value(_key, value)
  ['String', value[:string]]
end

#process_array_value(value) ⇒ Object



33
34
35
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 33

def process_array_value(value)
  process_typed_sequence(value)
end

#process_list_value(list) ⇒ Object



29
30
31
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 29

def process_list_value(list)
  process_typed_sequence(list)
end

#process_value(value) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/lutaml/lml/data_processor/value_processing.rb', line 21

def process_value(value)
  return [] if value.nil?
  return process_hash_value(value) if value.is_a?(Hash)
  return process_array_value(value) if value.is_a?(Array)

  [value.class.to_s, value]
end