Class: Blinksale::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/invoices.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'lib/invoices.rb', line 5

def currency
  @currency
end

#due_amountObject

Returns the value of attribute due_amount.



5
6
7
# File 'lib/invoices.rb', line 5

def due_amount
  @due_amount
end

#due_onObject

Returns the value of attribute due_on.



5
6
7
# File 'lib/invoices.rb', line 5

def due_on
  @due_on
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/invoices.rb', line 5

def id
  @id
end

#issued_onObject

Returns the value of attribute issued_on.



5
6
7
# File 'lib/invoices.rb', line 5

def issued_on
  @issued_on
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/invoices.rb', line 5

def number
  @number
end

#total_amountObject

Returns the value of attribute total_amount.



5
6
7
# File 'lib/invoices.rb', line 5

def total_amount
  @total_amount
end

Class Method Details

.from_node(node) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/invoices.rb', line 7

def self.from_node(node)
  self.new.tap do |i|
    i.id = node.attributes["uri"].content[/\d+$/].to_i
    i.number = node.xpath('xmlns:number').first.content
    i.total_amount = node.attributes["total"].content.to_f
    i.due_amount = node.attributes["total_due"].content.to_f
    i.issued_on = Date.strptime(node.xpath('xmlns:date').first.content, "%Y-%m-%d")
    i.due_on = Date.strptime(node.xpath('xmlns:terms').first.attributes["due_date"].content, "%Y-%m-%d")
    i.currency = node.xpath('xmlns:currency').first.content
  end
end