Class: GnuCash::Invoice::Customer
- Inherits:
-
Object
- Object
- GnuCash::Invoice::Customer
- Includes:
- Timestamps
- Defined in:
- lib/gnucash/invoice/customer.rb
Defined Under Namespace
Classes: CustomerNotFound
Constant Summary
Constants included from Timestamps
Instance Attribute Summary collapse
-
#addr_name ⇒ Object
readonly
Returns the value of attribute addr_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #address_lines ⇒ Object
-
#initialize(data) ⇒ Customer
constructor
A new instance of Customer.
Methods included from Timestamps
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_name ⇒ Object (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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/gnucash/invoice/customer.rb', line 10 def id @id end |
#name ⇒ Object (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_lines ⇒ Object
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 |