Class: Kabutops::RecipeItem
- Inherits:
-
Object
- Object
- Kabutops::RecipeItem
- Defined in:
- lib/kabutops/recipe_item.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(type, value) ⇒ RecipeItem
constructor
A new instance of RecipeItem.
- #process(resource, page) ⇒ Object
Constructor Details
#initialize(type, value) ⇒ RecipeItem
Returns a new instance of RecipeItem.
8 9 10 11 |
# File 'lib/kabutops/recipe_item.rb', line 8 def initialize type, value @type = type @value = value end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/kabutops/recipe_item.rb', line 6 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/kabutops/recipe_item.rb', line 6 def value @value end |
Instance Method Details
#process(resource, page) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kabutops/recipe_item.rb', line 13 def process resource, page case @type when :var resource[@value] when :recipe @value.process(resource, page) when :css page.css(@value).text when :xpath page.xpath(@value).text when :lambda, :proc @value.call(resource, page) else raise "unknown recipe item type '#{item.type}'" end end |