Class: Microformat::ItemProp

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

Class Method Summary collapse

Class Method Details

.parse(node, strict) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/microformat.rb', line 7

def self.parse(node, strict)
  # If the element has no itemprop attribute
  # The attribute must return null on getting and must throw an INVALID_ACCESS_ERR exception on setting.
  return nil unless node.attribute('itemprop')

  # If the element has an itemscope attribute
  # The attribute must return the element itself on getting and must throw an INVALID_ACCESS_ERR exception on setting.
  return ItemScope.new(node, strict) if node.attribute('itemscope')

  if strict
    parse_strict node
  else
    parse_weak node
  end
end