Class: EdifactConverter::Configuration::YAMLConfigurator

Inherits:
Object
  • Object
show all
Defined in:
lib/edifact_converter/configuration/yaml_configurator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeYAMLConfigurator

Returns a new instance of YAMLConfigurator.



10
11
12
# File 'lib/edifact_converter/configuration/yaml_configurator.rb', line 10

def initialize
  load
end

Instance Attribute Details

#binary_versionsObject

Returns the value of attribute binary_versions.



8
9
10
# File 'lib/edifact_converter/configuration/yaml_configurator.rb', line 8

def binary_versions
  @binary_versions
end

#default_nsObject

Returns the value of attribute default_ns.



8
9
10
# File 'lib/edifact_converter/configuration/yaml_configurator.rb', line 8

def default_ns
  @default_ns
end

Instance Method Details

#binary?(version) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/edifact_converter/configuration/yaml_configurator.rb', line 33

def binary?(version)
  binary_versions.include? version
end

#edifact_rules(type, segment_group) ⇒ Object



14
15
16
# File 'lib/edifact_converter/configuration/yaml_configurator.rb', line 14

def edifact_rules(type, segment_group)
  edifact_settings[type][segment_group]
end

#xml_rules(*args) ⇒ Object

Either namespace or type and version



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/edifact_converter/configuration/yaml_configurator.rb', line 18

def xml_rules(*args) #Either namespace or type and version
  case args.size
  when 1
    xml_settings[args.first]
  when 2
    rules = xml_settings.find do |namespace, values|
      values.versions && values.versions.include?(args[1])
    end
    rules &&= rules.last
    rules || xml_settings[default_ns] 
  else
    raise RuntimeError "Wrong number of arguments #{args.size}"
  end
end