Module: Semaph::Formatting
- Defined in:
- lib/semaph/formatting.rb
Constant Summary collapse
- TIME_FORMAT =
"%m-%d %H:%M".freeze
Class Method Summary collapse
- .hours_minutes_seconds(total_seconds) ⇒ Object
- .index(number) ⇒ Object
- .length(collection) ⇒ Object
- .time(time) ⇒ Object
Class Method Details
.hours_minutes_seconds(total_seconds) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/semaph/formatting.rb', line 11 def self.hours_minutes_seconds(total_seconds) seconds = total_seconds % 60 minutes = (total_seconds / 60) % 60 hours = total_seconds / (60 * 60) format("%02<hours>d:%02<minutes>d:%02<seconds>d", hours: hours, minutes: minutes, seconds: seconds) end |
.index(number) ⇒ Object
19 20 21 |
# File 'lib/semaph/formatting.rb', line 19 def self.index(number) Rainbow(number.to_s.rjust(2)).yellow end |
.length(collection) ⇒ Object
23 24 25 |
# File 'lib/semaph/formatting.rb', line 23 def self.length(collection) Rainbow(collection.length.to_s).cyan end |
.time(time) ⇒ Object
7 8 9 |
# File 'lib/semaph/formatting.rb', line 7 def self.time(time) time.strftime(TIME_FORMAT) end |