Class: Gnucash::Customer

Inherits:
Object
  • Object
show all
Includes:
Support::LightInspect
Defined in:
lib/gnucash/customer.rb

Overview

Represent a GnuCash customer object.

Since:

  • 1.6.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::LightInspect

#inspect

Constructor Details

#initialize(book, node) ⇒ Customer

Create an customer object.

Parameters:

  • book (Book)

    The Book containing the customer.

  • node (Nokogiri::XML::Node)

    Nokogiri XML node.

Since:

  • 1.6.0



28
29
30
31
32
33
34
35
36
# File 'lib/gnucash/customer.rb', line 28

def initialize(book, node)
  @book = book
  @node = node
  @name = node.xpath('cust:name').text
  @id = node.xpath('cust:id').text
  @guid = node.xpath('cust:guid').text
  @address = node.xpath('cust:addr').text
  @shipping_address = node.xpath('cust:shipaddr').text
end

Instance Attribute Details

#addressString (readonly)

Returns The address of the customer.

Returns:

  • (String)

    The address of the customer.

Since:

  • 1.6.0



19
20
21
# File 'lib/gnucash/customer.rb', line 19

def address
  @address
end

#guidString (readonly)

Returns The GUID of the customer.

Returns:

  • (String)

    The GUID of the customer.

Since:

  • 1.6.0



13
14
15
# File 'lib/gnucash/customer.rb', line 13

def guid
  @guid
end

#idString (readonly)

Returns The ID of the customer.

Returns:

  • (String)

    The ID of the customer.

Since:

  • 1.6.0



16
17
18
# File 'lib/gnucash/customer.rb', line 16

def id
  @id
end

#nameString (readonly)

Returns The name of the customer (unqualified).

Returns:

  • (String)

    The name of the customer (unqualified).

Since:

  • 1.6.0



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

def name
  @name
end

#shipping_addressString (readonly)

Returns The shipping address of the customer.

Returns:

  • (String)

    The shipping address of the customer.

Since:

  • 1.6.0



22
23
24
# File 'lib/gnucash/customer.rb', line 22

def shipping_address
  @shipping_address
end

Instance Method Details

#attributesArray<Symbol>

Attributes available for inspection

Returns:

  • (Array<Symbol>)

    Attributes used to build the inspection string

See Also:

Since:

  • 1.6.0



49
50
51
# File 'lib/gnucash/customer.rb', line 49

def attributes
  %i[id name guid address shipping_address]
end

#full_nameString

Return the fully qualified customer name.

Returns:

  • (String)

    Fully qualified customer name.

Since:

  • 1.6.0



41
42
43
# File 'lib/gnucash/customer.rb', line 41

def full_name
  name
end