Class: Pasta::Dish

Inherits:
Object
  • Object
show all
Defined in:
lib/pasta/dish.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#sauceObject (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