Class: Clasrip::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/clasrip.rb

Instance Method Summary collapse

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

#eachObject



75
76
77
78
79
# File 'lib/clasrip.rb', line 75

def each
  @records.each do |r|
    yield r
  end
end

#get_dateObject



94
95
96
# File 'lib/clasrip.rb', line 94

def get_date
  @dates[0]
end

#nextObject



71
72
73
# File 'lib/clasrip.rb', line 71

def next
  @records.next
end

#peekObject



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