Class: AdfBuilder::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/adf_builder/customer/customer.rb

Instance Method Summary collapse

Constructor Details

#initialize(prospect) ⇒ Customer

Returns a new instance of Customer.



3
4
5
6
7
8
9
# File 'lib/adf_builder/customer/customer.rb', line 3

def initialize(prospect)
  @customer = Ox::Element.new('customer')
  @contact = nil
  @timeframe = nil

  prospect << @customer
end

Instance Method Details

#add(name, opts = {}) ⇒ Object



18
19
20
# File 'lib/adf_builder/customer/customer.rb', line 18

def add(name, opts={})
  @contact = Contact.new(@customer, name, opts)
end

#add_id(index, value, source = nil, sequence = 1) ⇒ Object



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

def add_id(index, value, source=nil, sequence=1)
  if @prospect.locate("customer").empty?
    false
  else
    Id.new.add(@prospect.customer(index), value, source, sequence)
  end
end

#add_timeframe(description, earliest_date = nil, latest_date = nil) ⇒ Object

is present, it is required to specify earliestdate and/or latestdate is present, it is required to specify earliestdate and/or latestdate

Parameters:

  • descriptin (String)
    • Description of customer’s timing intention.

  • earliest_date (DateTime) (defaults to: nil)
    • Earliest date customer is interested in. If timeframe tag

  • latest_date (DateTime) (defaults to: nil)
    • Latest date customer is interested in. If timeframe tag



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/adf_builder/customer/customer.rb', line 37

def add_timeframe(description, earliest_date=nil, latest_date=nil)
  if earliest_date.nil? and latest_date.nil?
    return false
  end

  if earliest_date and earliest_date.class != DateTime
    return false
  end

  if latest_date and latest_date.class != DateTime
    return false
  end

  @timeframe = Timeframe.new(@customer, description, earliest_date, latest_date) if @timeframe.nil?
end

#contactObject



11
12
13
# File 'lib/adf_builder/customer/customer.rb', line 11

def contact
  @contact
end

#timeframeObject



15
16
17
# File 'lib/adf_builder/customer/customer.rb', line 15

def timeframe
  @timeframe
end

#update_comments(comments) ⇒ Object



53
54
55
56
# File 'lib/adf_builder/customer/customer.rb', line 53

def update_comments(comments)
  return false if comments.class != String
  AdfBuilder::Builder.update_node(@customer, :comments, comments)
end