Class: Harvester::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.xpath("./id").first.content.to_i
    i.number = node.xpath("./number").first.content
    i.total_amount = node.xpath("./amount").first.content.to_f
    i.due_amount = node.xpath("./due-amount").first.content.to_f
    i.issued_on = Date.strptime(node.xpath("./issued-at").first.content, "%Y-%m-%d")
    i.due_on = Date.strptime(node.xpath("./due-at").first.content, "%Y-%m-%d")
    i.currency = node.xpath("./currency").first.content[/\w{3}$/]
  end
end