Class: TimeOverlap::CLI
- Inherits:
-
Thor
- Object
- Thor
- TimeOverlap::CLI
- Defined in:
- lib/time_overlap/cli.rb
Instance Method Summary collapse
- #expert(from, to, min_overlap, base_time_zone, *time_zones) ⇒ Object
- #light(from, to, base_time_zone, *time_zones) ⇒ Object
- #list ⇒ Object
Instance Method Details
#expert(from, to, min_overlap, base_time_zone, *time_zones) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/time_overlap/cli.rb', line 13 def expert(from, to, min_overlap, base_time_zone, *time_zones) rows = [] header = "" header << "*** Your overlap hours in #{time_zones.join(", ")} to #{base_time_zone} (Expert view) ***\n".center(Presenter::WIDTH) rows << [header] puts Terminal::Table.new rows: rows, :style => { :width => Presenter::WIDTH + 4 } raise "Min overlap (#{min_overlap}) need to be Integer from range (1..24)" if min_overlap.to_i.zero? time_zones.each_with_index do |zone_name, index| TimeOverlap::Calculator.show( from: from.to_i, to: to.to_i, min_overlap: min_overlap.to_i, time_zone: base_time_zone, my_time_zone: zone_name, expert: true, ) end end |
#light(from, to, base_time_zone, *time_zones) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/time_overlap/cli.rb', line 40 def light(from, to, base_time_zone, *time_zones) rows = [] header = "" header << "*** Your overlap hours in #{time_zones.join(", ")} to #{base_time_zone} (Light view) ***".center(Presenter::WIDTH) rows << [header] puts Terminal::Table.new rows: rows, :style => { :width => Presenter::WIDTH + 4 } time_zones.each_with_index do |zone_name, index| TimeOverlap::Calculator.show( from: from.to_i, to: to.to_i, min_overlap: 0, time_zone: base_time_zone, my_time_zone: zone_name, expert: false, ) end end |
#list ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/time_overlap/cli.rb', line 61 def list puts "List of available time zones:" puts "-----------------------------" ActiveSupport::TimeZone.all.map do |zone| puts "#{ActiveSupport::TimeZone[zone.name].formatted_offset}: #{zone.name}" end puts "-----------------------------" self.help end |