Class: CLI
- Inherits:
-
Object
- Object
- CLI
- Defined in:
- lib/cli.rb
Constant Summary collapse
- MONTHS =
["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
9 10 11 12 |
# File 'lib/cli.rb', line 9 def initialize() @cache = {} @api = NationalDayList.new() end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
7 8 9 |
# File 'lib/cli.rb', line 7 def api @api end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cli.rb', line 14 def run puts "CLI for 'www.nationaldaycalendar.com'. Type 'help' for usage." loop do print '>' cmd = gets.chomp.split(" ") case cmd[0] when "exit" return; when "today" date = Date.today parseDateCommand([date.month.to_s, date.mday.to_s] + cmd[1..-1]) when 'help' puts "Type '1' or 'january' to view all national days for january." puts "Type '1 2' or 'january' first to view all national days for january second." puts "Type '1 2 4' to view the fourth national day for january second." puts "Month and day of month can be replaced with 'today' in all commands." puts "Type 'exit' to exit" else parseDateCommand(cmd); end end end |