Class: Mida::Itemscope

Inherits:
Object
  • Object
show all
Defined in:
lib/mida/itemscope.rb

Overview

Class that parses itemscope elements

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

The Global Identifier of the itemscope



12
13
14
# File 'lib/mida/itemscope.rb', line 12

def id
  @id
end

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

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