/usr/lib/ruby/vendor_ruby/faker/time.rb is in ruby-faker 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | module Faker
class Time < Date
TIME_RANGES = {
:all => (0..23),
:day => (9..17),
:night => (18..23),
:morning => (6..11),
:afternoon => (12..17),
:evening => (17..21),
:midnight => (0..4)
}
class << self
def between(from, to, period = :all)
super(from, to).to_time + random_time(period)
end
def forward(days = 365, period = :all)
super(days).to_time + random_time(period)
end
def backward(days = 365, period = :all)
super(days).to_time + random_time(period)
end
private
def random_time(period)
hours(period) + minutes + seconds
end
def hours(period)
raise ArgumentError, 'invalid period' unless TIME_RANGES.has_key? period
hour_at_period = TIME_RANGES[period].to_a.sample
(60 * 60 * hour_at_period)
end
def minutes
60 * seconds
end
def seconds
(0..59).to_a.sample
end
end
end
end
|