Class: TextInvoice::CLI
- Inherits:
-
Object
- Object
- TextInvoice::CLI
- Defined in:
- lib/text-invoice/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 |
# File 'lib/text-invoice/cli.rb', line 7 def initialize() @tasks = TextInvoice::Tasks.new @argv = ARGV @stdin = $stdin end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
5 6 7 |
# File 'lib/text-invoice/cli.rb', line 5 def argv @argv end |
#stdin ⇒ Object
Returns the value of attribute stdin.
5 6 7 |
# File 'lib/text-invoice/cli.rb', line 5 def stdin @stdin end |
#tasks ⇒ Object
Returns the value of attribute tasks.
5 6 7 |
# File 'lib/text-invoice/cli.rb', line 5 def tasks @tasks end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/text-invoice/cli.rb', line 13 def run() mode = @argv.shift if mode == "update" @tasks.totals(@stdin.read) elsif mode == "summary" @tasks.summary(@argv) elsif mode == "list" @tasks.list(@argv) elsif mode == "new" @tasks.new_invoice() elsif mode == "html" @tasks.html(@stdin.read) elsif mode == "template" template = @argv.shift if template @tasks.template(@stdin.read, template) else @tasks.usage() end else @tasks.usage() end end |