Class: Semantic::Mapper::Markup
- Inherits:
-
Object
- Object
- Semantic::Mapper::Markup
- Defined in:
- lib/semantic/mapper/markup.rb
Constant Summary collapse
- SELECTOR =
'[data-mapping]'
Instance Attribute Summary collapse
-
#mapped_hash ⇒ Object
readonly
Returns the value of attribute mapped_hash.
Instance Method Summary collapse
-
#initialize(html) ⇒ Markup
constructor
A new instance of Markup.
- #map ⇒ Object
Constructor Details
#initialize(html) ⇒ Markup
Returns a new instance of Markup.
7 8 9 10 |
# File 'lib/semantic/mapper/markup.rb', line 7 def initialize(html) @html = html @mapped_hash = HashWithIndifferentAccess.new end |
Instance Attribute Details
#mapped_hash ⇒ Object (readonly)
Returns the value of attribute mapped_hash.
5 6 7 |
# File 'lib/semantic/mapper/markup.rb', line 5 def mapped_hash @mapped_hash end |
Instance Method Details
#map ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/semantic/mapper/markup.rb', line 12 def map document.css(SELECTOR).each do |element| fields(element).each do |key| final_attribute_value = attribute_value(element, 'name') keys = build_keys(key) map_hash(final_attribute_value, keys) end end @mapped_hash end |