Class: FactoryHelper::Time

Inherits:
Date show all
Defined in:
lib/factory-helper/time.rb

Constant Summary collapse

TIME_RANGES =
{
  :all => (0..23),
  :day => (9..17),
  :night => (18..23),
  :morning => (6..11),
  :afternoon => (12..17),
  :evening => (17..21),
  :midnight => (0..4)
}

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Date

birthday

Methods inherited from Base

bothify, fetch, flexible, letterify, method_missing, numerify, parse, rand_in_range, regexify, translate

Class Method Details

.backward(days = 365, period = :all) ⇒ Object



24
25
26
# File 'lib/factory-helper/time.rb', line 24

def backward(days = 365, period = :all)
  super(days).to_time + random_time(period)
end

.between(from = ::Time.at(0), to = ::Time.now, period = :all) ⇒ Object



16
17
18
# File 'lib/factory-helper/time.rb', line 16

def between(from=::Time.at(0), to=::Time.now, period = :all)
  super(from, to).to_time + random_time(period)
end

.forward(days = 365, period = :all) ⇒ Object



20
21
22
# File 'lib/factory-helper/time.rb', line 20

def forward(days = 365, period = :all)
  super(days).to_time + random_time(period)
end