Class: TextInvoice::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/text-invoice/tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTasks

Returns a new instance of Tasks.



7
8
9
10
11
12
# File 'lib/text-invoice/tasks.rb', line 7

def initialize()
    @totals_calculator = TextInvoice::Totals.new
    @summary_calculator = TextInvoice::Summary.new
    @invoice = TextInvoice::Invoice
    @template = TextInvoice::Template.new
end

Instance Attribute Details

#invoiceObject

Returns the value of attribute invoice.



5
6
7
# File 'lib/text-invoice/tasks.rb', line 5

def invoice
  @invoice
end

#summary_calculatorObject

Returns the value of attribute summary_calculator.



5
6
7
# File 'lib/text-invoice/tasks.rb', line 5

def summary_calculator
  @summary_calculator
end

#template(invoice, template) ⇒ Object

Returns the value of attribute template.



5
6
7
# File 'lib/text-invoice/tasks.rb', line 5

def template
  @template
end

#totals_calculatorObject

Returns the value of attribute totals_calculator.



5
6
7
# File 'lib/text-invoice/tasks.rb', line 5

def totals_calculator
  @totals_calculator
end

Instance Method Details

#html(invoice) ⇒ Object



30
31
32
# File 'lib/text-invoice/tasks.rb', line 30

def html(invoice)
    @template.html(invoice)
end

#list(input) ⇒ Object



22
23
24
# File 'lib/text-invoice/tasks.rb', line 22

def list(input)
    @summary_calculator.list(input)
end

#new_invoiceObject



26
27
28
# File 'lib/text-invoice/tasks.rb', line 26

def new_invoice()
    @invoice.blank()
end

#summary(input) ⇒ Object



18
19
20
# File 'lib/text-invoice/tasks.rb', line 18

def summary(input)
    @summary_calculator.summary(input)
end

#totals(input) ⇒ Object



14
15
16
# File 'lib/text-invoice/tasks.rb', line 14

def totals(input)
    @totals_calculator.process(input)
end

#usageObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/text-invoice/tasks.rb', line 38

def usage()
    text = """
Usage: text-invoice [new|totals|summary|list|html|template] [additional arguments..]

new        Writes an empty invoice to STDOUT

update     Calculates subtotals, totals and due amounts
   Reads an invoice from STDIN and writes an updated invoice to STDOUT

summary    Returns a summary of invoice files.
   Summarises invoice files from additional arguments

list       Returns a summarised list of invoices
   Lists invoice files from additional arguments

html       Transforms an invoice to HTML using a built-in template
   Reads invoice from STDIN

template   Transforms an invoice to HTML using a custom Mustache template
   Reads invoice from STDIN. File path of a Mustache template must 
   be provided as an additional argument.
    """
end