Module: RSMP::Convert::Import::YAML

Defined in:
lib/rsmp/convert/import/yaml.rb

Class Method Summary collapse

Class Method Details

.convert(yaml) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rsmp/convert/import/yaml.rb', line 20

def self.convert yaml
  sxl = {
    alarms: {},
    statuses: {},
    commands: {}
  }

  yaml['objects'].each_pair do |type,object|  
    object["alarms"].each { |id,item| sxl[:alarms][id] = item }
    object["statuses"].each { |id,item| sxl[:statuses][id] = item }
    object["commands"].each { |id,item| sxl[:commands][id] = item }
  end
  sxl
end

.parse(str) ⇒ Object


16
17
18
# File 'lib/rsmp/convert/import/yaml.rb', line 16

def self.parse str
  convert ::YAML.load(str)
end

.read(path) ⇒ Object


12
13
14
# File 'lib/rsmp/convert/import/yaml.rb', line 12

def self.read path
  convert ::YAML.load_file(path)
end