Class: Semantic::Mapper::Markup

Inherits:
Object
  • Object
show all
Defined in:
lib/semantic/mapper/markup.rb

Constant Summary collapse

SELECTOR =
'[data-mapping]'

Instance Method Summary collapse

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

#mapObject



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