Class: Clasrip::Scraper
- Inherits:
-
Object
- Object
- Clasrip::Scraper
- Defined in:
- lib/clasrip.rb
Instance Method Summary collapse
- #each ⇒ Object
- #get_date ⇒ Object
-
#initialize(start_year, end_year) ⇒ Scraper
constructor
A new instance of Scraper.
- #next ⇒ Object
- #peek ⇒ Object
- #set_date(year, month, day) ⇒ Object
Constructor Details
#initialize(start_year, end_year) ⇒ Scraper
Returns a new instance of Scraper.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/clasrip.rb', line 58 def initialize(start_year, end_year) @dates = [ DatesBetween.new(start_year, end_year), DatesBetween.new(start_year, end_year) ] @dates[1].next @host_url = "www.classification.gov.au" @query_url = "/www/cob/find.nsf/classifications?search&searchwv=1&searchmax=1000&count=1000&query=(%%5BclassificationDate%%5D%%3E=%s)AND(%%5BclassificationDate%%5D%%3C%s)" new_conn new_enum end |
Instance Method Details
#each ⇒ Object
75 76 77 78 79 |
# File 'lib/clasrip.rb', line 75 def each @records.each do |r| yield r end end |
#get_date ⇒ Object
94 95 96 |
# File 'lib/clasrip.rb', line 94 def get_date @dates[0] end |
#next ⇒ Object
71 72 73 |
# File 'lib/clasrip.rb', line 71 def next @records.next end |
#peek ⇒ Object
81 82 83 |
# File 'lib/clasrip.rb', line 81 def peek @records.peek end |
#set_date(year, month, day) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/clasrip.rb', line 85 def set_date(year, month, day) @dates.each do |date| date.year = year.to_i date.month = month.to_i date.day = day.to_i end @dates[1].next end |