Class: Pasta::Dish
- Inherits:
-
Object
- Object
- Pasta::Dish
- Defined in:
- lib/pasta/dish.rb
Instance Attribute Summary collapse
-
#sauce ⇒ Object
readonly
Public: The source document that will be the subject of parsing.
Instance Method Summary collapse
-
#initialize(sauce) ⇒ Dish
constructor
Public: Creates a new Pasta::Dish.
-
#make(output) ⇒ Object
Public.
-
#with(recipe) ⇒ Object
Public: Looks up a recipe from the menu.
Constructor Details
#initialize(sauce) ⇒ Dish
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.
18 19 20 21 |
# File 'lib/pasta/dish.rb', line 18 def initialize(sauce) @sauce = sauce @recipe = Pasta::Recipes::Markdown.new end |
Instance Attribute Details
#sauce ⇒ Object (readonly)
Public: The source document that will be the subject of parsing.
7 8 9 |
# File 'lib/pasta/dish.rb', line 7 def sauce @sauce end |
Instance Method Details
#make(output) ⇒ Object
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
46 47 48 |
# File 'lib/pasta/dish.rb', line 46 def make(output) @recipe.send "to_#{output}", @sauce end |
#with(recipe) ⇒ Object
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
32 33 34 35 |
# File 'lib/pasta/dish.rb', line 32 def with(recipe) @receipe = check_cookbook_for recipe self end |