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 9 10 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 5 def initialize(minute_start=nil, minute_end=nil) @start = minute_start unless minute_start == minute_end @end = minute_end 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
17 18 19 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 17 def equals(t) @start == t.start && @end == t.end end |
#get ⇒ Object
12 13 14 15 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 12 def get return "off" if (@start.nil? && @end.nil?) "#{time_string(@start)}#{@end.nil? ? "" : "-#{time_string(@end)}"}" end |
#time_string(minutes) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/opening_hours_converter/opening_hours_time.rb', line 21 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 |