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.
- #reset ⇒ Object
Constructor Details
#initialize(*args, **kwargs) ⇒ Cli
Returns a new instance of Cli.
16 17 18 19 |
# File 'lib/schedule/cli.rb', line 16 def initialize(*args, **kwargs) Config.setup! super end |
Instance Method Details
#availability(type = nil, *offset_string) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/schedule/cli.rb', line 24 def availability(type = nil, *offset_string) config = Config.value(:defaults) if /\A\d+\z/.match?(type) config[:duration] = type.to_i else event_config = Config.value(:events, type&.to_sym) config = config.deep_merge(event_config) if event_config.present? 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.to_s if .debug? slots = Schedule::Calendar.new(config).free_slots "#{format_free_slots(slots)}<br/>#{config[:footer]}" end |
#config ⇒ Object
43 44 45 |
# File 'lib/schedule/cli.rb', line 43 def config system("${EDITOR:-${VISUAL:-vi}} '#{Config.config_file}'") end |
#reset ⇒ Object
48 49 50 |
# File 'lib/schedule/cli.rb', line 48 def reset system("rm -r #{Config::CONFIG_DIR}") end |