class UrlIncrementer::Inc

Attributes

current_url[RW]
offset[RW]
page_date[RW]
page_num[RW]
page_size[RW]
params[RW]
start_page[RW]
template[RW]
type[RW]

Public Class Methods

new(template, type=:offset, options = {}) click to toggle source
# File lib/url_incrementer.rb, line 7
def initialize(template, type=:offset, options = {})
  self.template = template
  self.type = type
  self.page_size = options[:page_size]
  self.offset = options[:offset] || 0
  self.page_num = options[:page_num] || 0
  # dates in next version
  # self.page_date = options[:page_date] || DateTime.now
end

Public Instance Methods

instance_variables_hash() click to toggle source
# File lib/url_incrementer.rb, line 29
def instance_variables_hash
  Hash[instance_variables.map { |name| [name.to_s.gsub('@', '').to_sym, instance_variable_get(name)] } ]
end
next() click to toggle source
# File lib/url_incrementer.rb, line 23
def next
  self.current_url = template % instance_variables_hash
  self.update_counters # must be after the line above because of the initial URL creation
  self.current_url
end
update_counters() click to toggle source
# File lib/url_incrementer.rb, line 17
def update_counters
  self.page_num += 1
  self.offset += self.page_size
  # self.page_date += 1
end