Class: EventScraper

Inherits:
Object
  • Object
show all
Includes:
CachedHtml
Defined in:
lib/event_scraper.rb

Constant Summary

Constants included from CachedHtml

CachedHtml::CACHE_DIR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CachedHtml

#cached_html, #filename, #munge

Constructor Details

#initializeEventScraper

Returns a new instance of EventScraper.



8
9
10
# File 'lib/event_scraper.rb', line 8

def initialize
  @doc = Nokogiri::HTML.parse(self.html)
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



6
7
8
# File 'lib/event_scraper.rb', line 6

def doc
  @doc
end

Instance Method Details

#htmlObject



12
13
14
# File 'lib/event_scraper.rb', line 12

def html
  @html ||= cached_html(about[:url])
end

#parseObject



16
17
18
19
20
21
22
# File 'lib/event_scraper.rb', line 16

def parse
  @res = []
  nodes.map {|n|
    @res << event(n)
  }
  @res
end

#parse_testObject



24
25
26
27
28
29
30
# File 'lib/event_scraper.rb', line 24

def parse_test
  nodes.each {|n|
    puts n.inner_html
    puts n.inner_text.gsub(/\s{2,}/, ' ').strip
    puts '-' * 80
  }
end