Class: Denso::Calendar::Cli
- Inherits:
-
Object
- Object
- Denso::Calendar::Cli
- Defined in:
- lib/denso/calendar/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #load_formatter ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
Returns a new instance of Cli.
15 16 17 18 19 20 21 22 23 |
# File 'lib/denso/calendar/cli.rb', line 15 def initialize(argv) require 'optparse' opt = OptionParser.new opt.on('-t TYPE', '--type TYPE') { |v| v } opt.on('-f FORMATTER', '--formatter FORMATTER') { |v| v } = {} opt.parse(argv, into: ) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/denso/calendar/cli.rb', line 13 def end |
Class Method Details
.run(options) ⇒ Object
9 10 11 |
# File 'lib/denso/calendar/cli.rb', line 9 def self.run() new().run end |
Instance Method Details
#load_formatter ⇒ Object
32 33 34 35 36 37 |
# File 'lib/denso/calendar/cli.rb', line 32 def load_formatter formatter_type = .fetch(:formatter, :plain) require "denso/calendar/formatter/#{formatter_type}" Denso::Calendar::Formatter.const_get(formatter_type.to_s.capitalize).new end |
#run ⇒ Object
25 26 27 28 29 30 |
# File 'lib/denso/calendar/cli.rb', line 25 def run calendar = Denso::Calendar.load([:type].to_sym) formatter = load_formatter puts formatter.format(calendar) end |