Module: Scraping::ClassMethods
- Includes:
- DSL
- Defined in:
- lib/scraping.rb
Instance Method Summary collapse
- #element(name) ⇒ Object
- #elements(name) ⇒ Object
-
#inherited(subclass) ⇒ Object
Make the rules inheritable, but prevent mutation of the original hash.
- #scrape(html) ⇒ Object
- #section(name) ⇒ Object
- #sections(name) ⇒ Object
Methods included from DSL
Instance Method Details
permalink #element(name) ⇒ Object
[View source]
37 38 39 40 |
# File 'lib/scraping.rb', line 37 def element(name, *) attr_accessor name super end |
permalink #elements(name) ⇒ Object
[View source]
42 43 44 45 |
# File 'lib/scraping.rb', line 42 def elements(name, *) attr_accessor name super end |
permalink #inherited(subclass) ⇒ Object
Make the rules inheritable, but prevent mutation of the original hash
33 34 35 |
# File 'lib/scraping.rb', line 33 def inherited(subclass) subclass.instance_variable_set(:@rules, rules.clone) end |
permalink #scrape(html) ⇒ Object
[View source]
57 58 59 |
# File 'lib/scraping.rb', line 57 def scrape(html) new(Nokogiri::HTML(html)).tap(&:scrape) end |
permalink #section(name) ⇒ Object
[View source]
47 48 49 50 |
# File 'lib/scraping.rb', line 47 def section(name, *) attr_accessor name super end |
permalink #sections(name) ⇒ Object
[View source]
52 53 54 55 |
# File 'lib/scraping.rb', line 52 def sections(name, *) attr_accessor name super end |