Class: ArchiveFinder
- Inherits:
-
Object
- Object
- ArchiveFinder
- Defined in:
- app/models/archive_finder.rb
Class Method Summary collapse
- .day_finder(finder, year, month, day) ⇒ Object
- .month_finder(finder, year, month) ⇒ Object
- .year_finder(finder, year) ⇒ Object
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
stub for page tag finding.
- #find(method, options = {}) ⇒ Object
-
#initialize(&block) ⇒ ArchiveFinder
constructor
A new instance of ArchiveFinder.
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, | start = Time.local(year, month, day) finish = start.tomorrow add_condition(, "published_at >= ? and published_at < ?", start, finish) finder.find(method, ) 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, | start = Time.local(year, month) finish = start.next_month add_condition(, "published_at >= ? and published_at < ?", start, finish) finder.find(method, ) 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, | start = Time.local(year) finish = start.next_year add_condition(, "published_at >= ? and published_at < ?", start, finish) finder.find(method, ) 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( ={}) self.find(:all, ) end |
#find(method, options = {}) ⇒ Object
7 8 9 |
# File 'app/models/archive_finder.rb', line 7 def find(method, = {}) @block.call(method, ) end |