Module: Scraping::ClassMethods
- Includes:
- DSL
- Defined in:
- lib/scraping.rb
Instance Method Summary collapse
- #element(name) ⇒ Object
- #elements(name) ⇒ Object
- #elements_of(name) ⇒ Object
-
#inherited(subclass) ⇒ Object
Make the rules inheritable, but prevent mutation of the original hash.
- #scrape(html) ⇒ Object
Methods included from DSL
Instance Method Details
#element(name) ⇒ Object
36 37 38 39 |
# File 'lib/scraping.rb', line 36 def element(name, *) attr_accessor name super end |
#elements(name) ⇒ Object
46 47 48 49 |
# File 'lib/scraping.rb', line 46 def elements(name, *) attr_accessor name super end |
#elements_of(name) ⇒ Object
41 42 43 44 |
# File 'lib/scraping.rb', line 41 def elements_of(name) attr_accessor name super end |
#inherited(subclass) ⇒ Object
Make the rules inheritable, but prevent mutation of the original hash
32 33 34 |
# File 'lib/scraping.rb', line 32 def inherited(subclass) subclass.instance_variable_set(:@rules, rules.clone) end |
#scrape(html) ⇒ Object
51 52 53 |
# File 'lib/scraping.rb', line 51 def scrape(html) new(Nokogiri::HTML(html)).tap(&:scrape) end |