Class: LabelMe::Order::Recipient

Inherits:
Object
  • Object
show all
Defined in:
lib/label_me/order/recipient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ Recipient

Returns a new instance of Recipient.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/label_me/order/recipient.rb', line 6

def initialize(row)
  @number       = row.recipient_id.to_i
  @name         = row.recipient_name
  @kana         = row.recipient_kana
  @address      = row.recipient_address
  @phone_number = row.recipient_phone_number
  @postal_code  = row.recipient_postal_code
  @labeling     = row.recipient_labeling
  @message_card = row.recipient_message_card_type.to_s +  " " + row.recipient_message_card_body.to_s
  @notes        = row.recipient_notes
  @wished_delivery_date     = row.wished_delivery_date
  @wished_delivery_timezone = row.wished_delivery_timezone
  @line_items   = [LabelMe::Order::LineItem.new(row)]
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



24
25
26
# File 'lib/label_me/order/recipient.rb', line 24

def address
  @address
end

#kanaObject

Returns the value of attribute kana.



23
24
25
# File 'lib/label_me/order/recipient.rb', line 23

def kana
  @kana
end

#labelingObject

Returns the value of attribute labeling.



27
28
29
# File 'lib/label_me/order/recipient.rb', line 27

def labeling
  @labeling
end

#line_itemsObject

Returns the value of attribute line_items.



32
33
34
# File 'lib/label_me/order/recipient.rb', line 32

def line_items
  @line_items
end

#message_cardObject

Returns the value of attribute message_card.



28
29
30
# File 'lib/label_me/order/recipient.rb', line 28

def message_card
  @message_card
end

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/label_me/order/recipient.rb', line 22

def name
  @name
end

#notesObject

Returns the value of attribute notes.



29
30
31
# File 'lib/label_me/order/recipient.rb', line 29

def notes
  @notes
end

#numberObject

Returns the value of attribute number.



21
22
23
# File 'lib/label_me/order/recipient.rb', line 21

def number
  @number
end

#phone_numberObject

Returns the value of attribute phone_number.



25
26
27
# File 'lib/label_me/order/recipient.rb', line 25

def phone_number
  @phone_number
end

#postal_codeObject

Returns the value of attribute postal_code.



26
27
28
# File 'lib/label_me/order/recipient.rb', line 26

def postal_code
  @postal_code
end

#wished_delivery_dateObject

Returns the value of attribute wished_delivery_date.



30
31
32
# File 'lib/label_me/order/recipient.rb', line 30

def wished_delivery_date
  @wished_delivery_date
end

#wished_delivery_timezoneObject

Returns the value of attribute wished_delivery_timezone.



31
32
33
# File 'lib/label_me/order/recipient.rb', line 31

def wished_delivery_timezone
  @wished_delivery_timezone
end

Instance Method Details

#===(other) ⇒ Object



51
52
53
# File 'lib/label_me/order/recipient.rb', line 51

def ===(other)
  self.number == other.number
end

#to_hashObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/label_me/order/recipient.rb', line 34

def to_hash
  {
    number:       number,
    name:         name,
    kana:         kana,
    address:      address,
    phone_number: phone_number,
    postal_code:  postal_code,
    labeling:     labeling,
    message_card: message_card,
    notes:        notes,
    wished_delivery_date:     wished_delivery_date,
    wished_delivery_timezone: wished_delivery_timezone,
    line_items_attributes: line_items.map(&:to_hash)
  }
end