class Biz::DayOfWeek
Constants
- ALL
- SYMBOLS
Attributes
wday[R]
Public Class Methods
all()
click to toggle source
# File lib/biz/day_of_week.rb, line 10 def self.all ALL end
from_symbol(symbol)
click to toggle source
# File lib/biz/day_of_week.rb, line 14 def self.from_symbol(symbol) ALL.fetch(SYMBOLS.index(symbol)) end
new(wday)
click to toggle source
# File lib/biz/day_of_week.rb, line 20 def initialize(wday) @wday = Integer(wday) end
Public Instance Methods
contains?(week_minute)
click to toggle source
# File lib/biz/day_of_week.rb, line 24 def contains?(week_minute) minutes.cover?(week_minute) end
day_minute(week_minute)
click to toggle source
# File lib/biz/day_of_week.rb, line 44 def day_minute(week_minute) (week_minute - 1) % Time.day_minutes + 1 end
end_minute()
click to toggle source
# File lib/biz/day_of_week.rb, line 32 def end_minute start_minute + Time.day_minutes end
minutes()
click to toggle source
# File lib/biz/day_of_week.rb, line 36 def minutes start_minute..end_minute end
start_minute()
click to toggle source
# File lib/biz/day_of_week.rb, line 28 def start_minute wday * Time.day_minutes end
symbol()
click to toggle source
# File lib/biz/day_of_week.rb, line 48 def symbol SYMBOLS.fetch(wday) end
wday?(other_wday)
click to toggle source
# File lib/biz/day_of_week.rb, line 52 def wday?(other_wday) wday == other_wday end
week_minute(day_minute)
click to toggle source
# File lib/biz/day_of_week.rb, line 40 def week_minute(day_minute) start_minute + day_minute end
Private Instance Methods
<=>(other)
click to toggle source
# File lib/biz/day_of_week.rb, line 58 def <=>(other) return unless other.is_a?(self.class) wday <=> other.wday end