Class: Mg2en::Parser
- Inherits:
-
Object
- Object
- Mg2en::Parser
- Defined in:
- lib/mg2en/parser.rb
Overview
Parse a MacGourmet 3 Plist export file into array of recipe objects.
Instance Attribute Summary collapse
-
#recipes ⇒ Object
readonly
Returns the value of attribute recipes.
Instance Method Summary collapse
-
#initialize(filename_or_xml) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(filename_or_xml) ⇒ Parser
Returns a new instance of Parser.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mg2en/parser.rb', line 8 def initialize(filename_or_xml) recipe_input = Plist.parse_xml(filename_or_xml) fail ArgumentError, 'Unable to parse input' unless recipe_input @recipes = [] recipe_input.each do |r| recipe = Mg2en::Recipe.new(r) @recipes.push recipe end end |
Instance Attribute Details
#recipes ⇒ Object (readonly)
Returns the value of attribute recipes.
7 8 9 |
# File 'lib/mg2en/parser.rb', line 7 def recipes @recipes end |