class Denso::Calendar::Cli
Attributes
options[R]
Public Class Methods
new(argv)
click to toggle source
# 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 } @options = {} opt.parse(argv, into: @options) end
run(options)
click to toggle source
# File lib/denso/calendar/cli.rb, line 9 def self.run(options) new(options).run end
Public Instance Methods
load_formatter()
click to toggle source
# File lib/denso/calendar/cli.rb, line 32 def load_formatter formatter_type = options.fetch(:formatter, :plain) require "denso/calendar/formatter/#{formatter_type}" Denso::Calendar::Formatter.const_get(formatter_type.to_s.capitalize).new end
run()
click to toggle source
# File lib/denso/calendar/cli.rb, line 25 def run calendar = Denso::Calendar.load(options[:type].to_sym) formatter = load_formatter puts formatter.format(calendar) end