Class: DssParser::Parser::States

Inherits:
Object
  • Object
show all
Defined in:
lib/dss_parser/parsers/states.rb

Class Method Summary collapse

Class Method Details

.parse(lines) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dss_parser/parsers/states.rb', line 4

def self.parse(lines)
  states = []
  Struct.new("State", :name, :description) unless defined?(Struct::State)

  lines.each do |line|
    type, content = line.split(" ", 2)

    if type == "@state"
      name, description = content.split("-", 2)

      states.push(Struct::State.new(name.strip, description.strip))
    end
  end

  return {states: states}
end