Module: Html2record::ActiveRecord
- Defined in:
- lib/html2record/orm/activerecord.rb
Instance Method Summary collapse
Instance Method Details
#apply_html(paser_class, html, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/html2record/orm/activerecord.rb', line 7 def apply_html(paser_class,html,&block) doc = Nokogiri::HTML.parse(html) paser_class.parsers.each do |x| column = x[:column] selector = x[:selector] xblock = x[:block] content= '' element = doc.css(selector) if xblock.nil? element = element.first if element.kind_of?(Array) content = element.text else content = xblock.call(element) end write_attribute(column,content) end end |