Class: Mida::Itemscope
- Inherits:
-
Object
- Object
- Mida::Itemscope
- Defined in:
- lib/mida/itemscope.rb
Overview
Class that parses itemscope elements
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
The Global Identifier of the itemscope.
-
#properties ⇒ Object
readonly
A Hash representing the properties as name/values paris The values will be an array containing either
String
orMida::Item
instances. -
#type ⇒ Object
readonly
The Type of the itemscope.
Class Method Summary collapse
-
.parse(itemscope, page_url = nil) ⇒ Object
Same as
new
for convenience.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(itemscope_node, page_url = nil) ⇒ Itemscope
constructor
Create a new Itemscope object.
Constructor Details
#initialize(itemscope_node, page_url = nil) ⇒ Itemscope
Create a new Itemscope object
- itemscope_node
-
The itemscope_node that you want to parse.
- page_url
-
The url of target used for form absolute url.
23 24 25 26 27 28 29 |
# File 'lib/mida/itemscope.rb', line 23 def initialize(itemscope_node, page_url=nil) @itemscope_node, @page_url = itemscope_node, page_url @type, @id = extract_attribute('itemtype'), extract_attribute('itemid') @properties = {} add_itemref_properties parse_elements(extract_elements(@itemscope_node)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
The Global Identifier of the itemscope
12 13 14 |
# File 'lib/mida/itemscope.rb', line 12 def id @id end |
#properties ⇒ Object (readonly)
A Hash representing the properties as name/values paris The values will be an array containing either String
or Mida::Item
instances
17 18 19 |
# File 'lib/mida/itemscope.rb', line 17 def properties @properties end |
#type ⇒ Object (readonly)
The Type of the itemscope
9 10 11 |
# File 'lib/mida/itemscope.rb', line 9 def type @type end |
Class Method Details
.parse(itemscope, page_url = nil) ⇒ Object
Same as new
for convenience
32 33 34 |
# File 'lib/mida/itemscope.rb', line 32 def self.parse(itemscope, page_url=nil) self.new itemscope, page_url end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 |
# File 'lib/mida/itemscope.rb', line 36 def ==(other) @type == other.type && @id == other.id && @properties == other.properties end |