Class: Biz::WeekTime::Abstract

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
AbstractType, Comparable, Memoizable
Defined in:
lib/biz/week_time/abstract.rb

Direct Known Subclasses

End, Start

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(week_minute) ⇒ Abstract

Returns a new instance of Abstract.



21
22
23
# File 'lib/biz/week_time/abstract.rb', line 21

def initialize(week_minute)
  @week_minute = Integer(week_minute)
end

Instance Attribute Details

#week_minuteObject (readonly)

Returns the value of attribute week_minute.



19
20
21
# File 'lib/biz/week_time/abstract.rb', line 19

def week_minute
  @week_minute
end

Class Method Details

.from_time(time) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/biz/week_time/abstract.rb', line 11

def self.from_time(time)
  new(
    time.wday * Time::MINUTES_IN_DAY +
      time.hour * Time::MINUTES_IN_HOUR +
      time.min
  )
end

Instance Method Details

#coerce(other) ⇒ Object



29
30
31
# File 'lib/biz/week_time/abstract.rb', line 29

def coerce(other)
  [self.class.new(other), self]
end

#wday_symbolObject



25
26
27
# File 'lib/biz/week_time/abstract.rb', line 25

def wday_symbol
  day_of_week.symbol
end