Class: Semantic::Mapper::Markup
- Inherits:
-
Object
- Object
- Semantic::Mapper::Markup
- Defined in:
- lib/semantic/mapper/markup.rb
Constant Summary collapse
- SELECTOR =
'[data-mapping]'
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.
6 7 8 |
# File 'lib/semantic/mapper/markup.rb', line 6 def initialize(html) @html = html end |
Instance Method Details
#map ⇒ Object
10 11 12 13 14 15 |
# File 'lib/semantic/mapper/markup.rb', line 10 def map document.css(SELECTOR).inject({}) do |hash, element| hash[attribute_value(element, 'data-mapping')] = attribute_value(element, 'name') hash end.with_indifferent_access end |