Class: Carddav::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/carddav/card.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Card

Returns a new instance of Card.



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

def initialize(data)
  @raw = data.to_s
  @parsed = VCardigan.parse self.class.normalize(data)
end

Instance Attribute Details

#parsedObject (readonly)

Returns the value of attribute parsed.



2
3
4
# File 'lib/carddav/card.rb', line 2

def parsed
  @parsed
end

#rawObject (readonly)

Returns the value of attribute raw.



2
3
4
# File 'lib/carddav/card.rb', line 2

def raw
  @raw
end

Class Method Details

.normalize(data) ⇒ Object



4
5
6
# File 'lib/carddav/card.rb', line 4

def self.normalize(data)
  data.to_s.gsub '&#13', ''
end

Instance Method Details

#emailObject



17
18
19
# File 'lib/carddav/card.rb', line 17

def email
  vcard_field :email
end

#imageObject



21
22
23
# File 'lib/carddav/card.rb', line 21

def image
  vcard_field :photo
end

#nameObject



13
14
15
# File 'lib/carddav/card.rb', line 13

def name
  vcard_field :fn
end