Class: Bmf::Dialog::DialogParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bmf-dialog/parser/dialog_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dialog) ⇒ DialogParser

Returns a new instance of DialogParser.



6
7
8
9
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 6

def initialize(dialog)
  @dialog = dialog
  @lines = []
end

Instance Attribute Details

#dialogObject (readonly)

Returns the value of attribute dialog.



5
6
7
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 5

def dialog
  @dialog
end

#linesObject (readonly)

Returns the value of attribute lines.



5
6
7
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 5

def lines
  @lines
end

Instance Method Details

#parseObject



11
12
13
14
15
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 11

def parse
  @dialog.scan(/^(.*?): (.*?)$/) do |m|
    @lines << Line.new(*m)
  end
end

#to_aObject



17
18
19
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 17

def to_a
  @lines.map(&:to_hash)
end