class Pasta::Dish
Attributes
sauce[R]
Public: The source document that will be the subject of parsing.
Public Class Methods
new(sauce)
click to toggle source
Public: Creates a new Pasta::Dish
.
sauce - The String document to be parsed. Required
Example
Pasta::Dish.new 'Some yummy text to parse'
Returns a new Pasta::Dish
.
# File lib/pasta/dish.rb, line 18 def initialize(sauce) @sauce = sauce @recipe = Pasta::Recipes::Markdown.new end
Public Instance Methods
make(output)
click to toggle source
Public. Converts the sauce to an output according to a recipe. Raises a Pasta::Error
is the recipe
doesn't have a to_x method
Example
make(:html) # => '<p>....</p>'
Returns a String of the converted root
# File lib/pasta/dish.rb, line 46 def make(output) @recipe.send "to_#{output}", @sauce end
with(recipe)
click to toggle source
Public: Looks up a recipe from the menu
recipe - A Symbol specifying the recipe to use when parsing and outputing
Example
with(:markdown)
Returns Self
# File lib/pasta/dish.rb, line 32 def with(recipe) @receipe = check_cookbook_for recipe self end
Private Instance Methods
check_cookbook_for(recipe)
click to toggle source
Private. Checks the cookbook for a recipe, raising an error if not found.
Returns the @recipe
# File lib/pasta/dish.rb, line 57 def check_cookbook_for recipe raise Pasta::Error.new "Recipe '#{recipe}' wasn't found in the cookbook" unless Recipes.const_defined? "#{recipe.to_s.capitalize}" Recipes.const_get("#{recipe.to_s.capitalize}").new end