Class: Valerie::Card

Inherits:
Object
  • Object
show all
Extended by:
Valerie::Core::Parser
Defined in:
lib/valerie/card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Valerie::Core::Parser

parse

Instance Attribute Details

#birthdayObject

Returns the value of attribute birthday.



8
9
10
# File 'lib/valerie/card.rb', line 8

def birthday
  @birthday
end

#formatted_nameObject (readonly)

Returns the value of attribute formatted_name.



8
9
10
# File 'lib/valerie/card.rb', line 8

def formatted_name
  @formatted_name
end

#genderObject

Returns the value of attribute gender.



8
9
10
# File 'lib/valerie/card.rb', line 8

def gender
  @gender
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/valerie/card.rb', line 8

def name
  @name
end

#organizationObject

Returns the value of attribute organization.



8
9
10
# File 'lib/valerie/card.rb', line 8

def organization
  @organization
end

Instance Method Details

#addressesObject



44
45
46
# File 'lib/valerie/card.rb', line 44

def addresses
  @addresses ||= Collection::AddressCollection.new
end

#emailsObject



40
41
42
# File 'lib/valerie/card.rb', line 40

def emails
  @emails ||= Collection::EmailCollection.new
end

#phonesObject



48
49
50
# File 'lib/valerie/card.rb', line 48

def phones
  @phones ||= Collection::PhoneCollection.new
end

#to_aObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/valerie/card.rb', line 56

def to_a
  parts = [
    'BEGIN:VCARD',
    "VERSION:#{Valerie.configuration.version}",
    "PRODID:-//#{Valerie.configuration.product}//#{Valerie.configuration.language}",
  ]
  
  parts << @name.to_s if @name
  parts << @organization.to_s if @organization
  parts << @birthday.to_s if @birthday
  parts << @gender.to_s if @gender
  
  emails.each do |email|
    parts << email.to_s
  end
  
  phones.each do |phone|
    parts << phone.to_s
  end
  
  addresses.each do |address|
    parts << address.to_s
  end
  
  parts << 'END:VCARD'
  parts
end

#to_sObject



52
53
54
# File 'lib/valerie/card.rb', line 52

def to_s
  to_a.join("\r\n")
end