Module: RSMP::Convert::Import::YAML
- Defined in:
- lib/rsmp_schema/convert/import/yaml.rb
Overview
Reads SXL definitions from YAML files.
Class Method Summary collapse
- .collect_objects(objects, sxl) ⇒ Object
- .convert(yaml) ⇒ Object
- .parse(str) ⇒ Object
- .read(path) ⇒ Object
Class Method Details
.collect_objects(objects, sxl) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rsmp_schema/convert/import/yaml.rb', line 29 def self.collect_objects(objects, sxl) 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 end |
.convert(yaml) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rsmp_schema/convert/import/yaml.rb', line 22 def self.convert(yaml) sxl = { meta: {}, alarms: {}, statuses: {}, commands: {} } sxl[:meta] = yaml['meta'] collect_objects yaml['objects'], sxl sxl end |
.parse(str) ⇒ Object
18 19 20 |
# File 'lib/rsmp_schema/convert/import/yaml.rb', line 18 def self.parse(str) convert ::YAML.safe_load(str) end |
.read(path) ⇒ Object
14 15 16 |
# File 'lib/rsmp_schema/convert/import/yaml.rb', line 14 def self.read(path) convert ::YAML.load_file(path) end |