Class: Bmf::Dialog::DialogParser
- Inherits:
-
Object
- Object
- Bmf::Dialog::DialogParser
- Defined in:
- lib/bmf-dialog/parser/dialog_parser.rb
Instance Attribute Summary collapse
-
#dialog ⇒ Object
readonly
Returns the value of attribute dialog.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
-
#initialize(dialog) ⇒ DialogParser
constructor
A new instance of DialogParser.
- #parse ⇒ Object
- #to_a ⇒ Object
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
#dialog ⇒ Object (readonly)
Returns the value of attribute dialog.
5 6 7 |
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 5 def dialog @dialog end |
#lines ⇒ Object (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
#parse ⇒ Object
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_a ⇒ Object
17 18 19 |
# File 'lib/bmf-dialog/parser/dialog_parser.rb', line 17 def to_a @lines.map(&:to_hash) end |