Class: OpeningHoursConverter::OpeningHoursTime
- Inherits:
-
Object
- Object
- OpeningHoursConverter::OpeningHoursTime
- Defined in:
- lib/opening_hours_converter/opening_hours_time.rb
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #equals(t) ⇒ Object
- #get ⇒ Object
-
#initialize(minute_start = nil, minute_end = nil) ⇒ OpeningHoursTime
constructor
A new instance of OpeningHoursTime.
- #time_string(minutes) ⇒ Object
Constructor Details
#initialize(minute_start = nil, minute_end = nil) ⇒ OpeningHoursTime
Returns a new instance of OpeningHoursTime.
5 6 7 8 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 5 def initialize(minute_start = nil, minute_end = nil) @start = minute_start @end = minute_end unless minute_start == minute_end end |
Instance Attribute Details
#end ⇒ Object (readonly)
Returns the value of attribute end.
3 4 5 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 3 def end @end end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
3 4 5 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 3 def priority @priority end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
3 4 5 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 3 def start @start end |
Instance Method Details
#equals(t) ⇒ Object
15 16 17 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 15 def equals(t) @start == t.start && @end == t.end end |
#get ⇒ Object
10 11 12 13 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 10 def get return 'off' if @start.nil? && @end.nil? "#{time_string(@start)}#{@end.nil? ? '' : "-#{time_string(@end)}"}" end |
#time_string(minutes) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 19 def time_string(minutes) fminutes = minutes.to_f h = (fminutes / 60).floor.to_i m = (fminutes % 60).to_i "#{h < 10 ? '0' : ''}#{h}:#{m < 10 ? '0' : ''}#{m}" end |