Class: ArchiveFinder

Inherits:
Object
  • Object
show all
Defined in:
app/models/archive_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ArchiveFinder

Returns a new instance of ArchiveFinder.



3
4
5
# File 'app/models/archive_finder.rb', line 3

def initialize(&block)
  @block = block
end

Class Method Details

.day_finder(finder, year, month, day) ⇒ Object



35
36
37
38
39
40
41
42
# File 'app/models/archive_finder.rb', line 35

def day_finder(finder, year, month, day)
  new do |method, options|
    start = Time.local(year, month, day)
    finish = start.tomorrow
    add_condition(options, "published_at >= ? and published_at < ?", start, finish)
    finder.find(method, options)
  end
end

.month_finder(finder, year, month) ⇒ Object



26
27
28
29
30
31
32
33
# File 'app/models/archive_finder.rb', line 26

def month_finder(finder, year, month)
  new do |method, options|
    start = Time.local(year, month)
    finish = start.next_month
    add_condition(options, "published_at >= ? and published_at < ?", start, finish)
    finder.find(method, options)
  end
end

.year_finder(finder, year) ⇒ Object



17
18
19
20
21
22
23
24
# File 'app/models/archive_finder.rb', line 17

def year_finder(finder, year)
  new do |method, options|
    start = Time.local(year)
    finish = start.next_year
    add_condition(options, "published_at >= ? and published_at < ?", start, finish)
    finder.find(method, options)
  end
end

Instance Method Details

#all(options = {}) ⇒ Object

stub for page tag finding



12
13
14
# File 'app/models/archive_finder.rb', line 12

def all(options ={})
  self.find(:all, options)
end

#find(method, options = {}) ⇒ Object



7
8
9
# File 'app/models/archive_finder.rb', line 7

def find(method, options = {})
  @block.call(method, options)
end