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.
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.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.to_s if .debug? slots = Schedule::Calendar.new(config).free_slots "#{format_free_slots(slots)}<br/>#{Config.value(:footer)}" end |
#config ⇒ Object
40 41 42 |
# File 'lib/schedule/cli.rb', line 40 def config system("${EDITOR:-${VISUAL:-vi}} '#{Config.config_file}'") end |
#reset ⇒ Object
45 46 47 |
# File 'lib/schedule/cli.rb', line 45 def reset system("rm -r #{Config::CONFIG_DIR}") end |