Class: BeerRecipe::RecipeReader

Inherits:
Object
  • Object
show all
Defined in:
lib/beer_recipe/recipe_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RecipeReader

Returns a new instance of RecipeReader.



4
5
6
# File 'lib/beer_recipe/recipe_reader.rb', line 4

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#parserObject

Returns the value of attribute parser.



2
3
4
# File 'lib/beer_recipe/recipe_reader.rb', line 2

def parser
  @parser
end

#recipeObject

Returns the value of attribute recipe.



2
3
4
# File 'lib/beer_recipe/recipe_reader.rb', line 2

def recipe
  @recipe
end

Instance Method Details

#outputObject



18
19
20
21
# File 'lib/beer_recipe/recipe_reader.rb', line 18

def output
  @options[:formatter].format(recipe)
  self
end

#readObject



8
9
10
11
12
# File 'lib/beer_recipe/recipe_reader.rb', line 8

def read
  @parser ||= NRB::BeerXML::Parser.new
  @beerxml = parser.parse @options[:file]
  self
end