Class: Schedule::Cli
- Inherits:
-
Thor
- Object
- Thor
- Schedule::Cli
- Defined in:
- lib/schedule/cli.rb
Instance Method Summary collapse
- #availability(type = nil, *offset_string) ⇒ Object
- #config ⇒ Object
-
#initialize(*args, **kwargs) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(*args, **kwargs) ⇒ Cli
Returns a new instance of Cli.
14 15 16 17 |
# File 'lib/schedule/cli.rb', line 14 def initialize(*args, **kwargs) Config.setup! super end |
Instance Method Details
#availability(type = nil, *offset_string) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/schedule/cli.rb', line 22 def availability(type = nil, *offset_string) config = Config.values.slice(:calendars, :day).merge(Config.value(:defaults)) if /\A\d+\z/.match(type) config[:duration] = type.to_i else config.merge!(Config.value(:events, type&.to_sym) || {}) end if offset_string.present? config[:day_offset] = parse_offset offset_string.join(' ') elsif config[:day_offset].is_a?(String) config[:day_offset] = parse_offset config[:day_offset] end puts "#{config}" if .debug? slots = Schedule::Calendar.new(config).free_slots format_free_slots(slots) end |
#config ⇒ Object
40 41 42 |
# File 'lib/schedule/cli.rb', line 40 def config system("${EDITOR:-${VISUAL:-vi}} '#{Config.config_file}'") end |