Class: Tod::TimeOfDay

Inherits:
Object
  • Object
show all
Defined in:
lib/aenea/time_of_day.rb

Defined Under Namespace

Classes: Type

Instance Method Summary collapse

Instance Method Details

#to_ampmObject



6
7
8
9
10
11
# File 'lib/aenea/time_of_day.rb', line 6

def to_ampm
  am_or_pm = hour < 12 ? 'am' : 'pm'
  ampm_hour = hour == 0 ? 12 : (hour > 12 ? hour - 12 : hour)

  sprintf('%d:%02d%s', ampm_hour, minute, am_or_pm)
end

#to_select_valueObject



13
14
15
# File 'lib/aenea/time_of_day.rb', line 13

def to_select_value
  [to_ampm, to_s]
end