Class: GnuCash::Invoice::Customer

Inherits:
Object
  • Object
show all
Includes:
Timestamps
Defined in:
lib/gnucash/invoice/customer.rb

Defined Under Namespace

Classes: CustomerNotFound

Constant Summary

Constants included from Timestamps

Timestamps::FORMAT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Timestamps

#from_timestamp

Constructor Details

#initialize(data) ⇒ Customer

Returns a new instance of Customer.



13
14
15
16
17
18
19
# File 'lib/gnucash/invoice/customer.rb', line 13

def initialize data
  @raw        = data

  @id         = data[:id]
  @name       = data[:name]
  @addr_name  = data[:addr_name]
end

Instance Attribute Details

#addr_nameObject (readonly)

Returns the value of attribute addr_name.



10
11
12
# File 'lib/gnucash/invoice/customer.rb', line 10

def addr_name
  @addr_name
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/gnucash/invoice/customer.rb', line 10

def id
  @id
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



10
11
12
# File 'lib/gnucash/invoice/customer.rb', line 10

def name
  @name
end

Class Method Details

.find(guid) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/gnucash/invoice/customer.rb', line 35

def self.find guid
  unless data = dataset.where(:guid => guid).first
    raise CustomerNotFound, "GUID: #{guid}"
  end

  new(data)
end

Instance Method Details

#address_linesObject



22
23
24
25
26
27
28
29
# File 'lib/gnucash/invoice/customer.rb', line 22

def address_lines
  @address_lines ||= [].tap do |lines|
    (1..4).each do |i|
      id = :"addr_addr#{i}"
      lines << @raw[id] if @raw[id]
    end
  end
end