Module: Fatboy::Helpers

Defined in:
lib/fatboy/helpers.rb

Overview

Common helper functions, which are used across many classes.

Class Method Summary collapse

Class Method Details

.all_format(time) ⇒ Object

Get an array of the hour format, the day format, the month format, and the year format


38
39
40
41
42
# File 'lib/fatboy/helpers.rb', line 38

def self.all_format(time)
  [:hour_format, :day_format, :month_format, :year_format].map do |func|
    self.send(func, time)
  end
end

.day_format(day) ⇒ Object

Properly format the time to retrieve or set a day


20
21
22
# File 'lib/fatboy/helpers.rb', line 20

def self.day_format(day)
  day.utc.strftime(Fatboy::DAY_FORMAT_STR)
end

.format_store(model_name, store_name) ⇒ Object

Given a model_name and the properly formated hour, day, etc. string, give the name of the key views are stored in


9
10
11
# File 'lib/fatboy/helpers.rb', line 9

def self.format_store(model_name, store_name)
  "#{model_name}-#{store_name}"
end

.hour_format(hr) ⇒ Object

Properly format the time to retrieve or set an hour


14
15
16
# File 'lib/fatboy/helpers.rb', line 14

def self.hour_format(hr)
  hr.utc.strftime(Fatboy::HOUR_FORMAT_STR)
end

.month_format(mth) ⇒ Object

Properly format the time to retrieve or set a month


26
27
28
# File 'lib/fatboy/helpers.rb', line 26

def self.month_format(mth)
  mth.utc.strftime(Fatboy::MONTH_FORMAT_STR)
end

.year_format(yr) ⇒ Object

Properly format the time to retrieve or set a year


32
33
34
# File 'lib/fatboy/helpers.rb', line 32

def self.year_format(yr)
  yr.utc.strftime(Fatboy::YEAR_FORMAT_STR)
end