Class: Harvester::Invoice
- Inherits:
-
Object
- Object
- Harvester::Invoice
- Defined in:
- lib/invoices.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#due_amount ⇒ Object
Returns the value of attribute due_amount.
-
#due_on ⇒ Object
Returns the value of attribute due_on.
-
#id ⇒ Object
Returns the value of attribute id.
-
#issued_on ⇒ Object
Returns the value of attribute issued_on.
-
#number ⇒ Object
Returns the value of attribute number.
-
#total_amount ⇒ Object
Returns the value of attribute total_amount.
Class Method Summary collapse
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
5 6 7 |
# File 'lib/invoices.rb', line 5 def currency @currency end |
#due_amount ⇒ Object
Returns the value of attribute due_amount.
5 6 7 |
# File 'lib/invoices.rb', line 5 def due_amount @due_amount end |
#due_on ⇒ Object
Returns the value of attribute due_on.
5 6 7 |
# File 'lib/invoices.rb', line 5 def due_on @due_on end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/invoices.rb', line 5 def id @id end |
#issued_on ⇒ Object
Returns the value of attribute issued_on.
5 6 7 |
# File 'lib/invoices.rb', line 5 def issued_on @issued_on end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/invoices.rb', line 5 def number @number end |
#total_amount ⇒ Object
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 |