Module: VisitCard::Models::Vcard::InstanceMethods

Defined in:
lib/visit_card/models/vcard.rb

Instance Method Summary collapse

Instance Method Details

#fgaObject



42
43
44
# File 'lib/visit_card/models/vcard.rb', line 42

def fga
  "#{family_name} #{given_name} #{additional_name}".strip
end

#fnObject



33
34
35
36
# File 'lib/visit_card/models/vcard.rb', line 33

def fn
  fn = "#{honorific_prefix} #{given_name} #{additional_name} #{family_name} #{honorific_suffix}".squeeze(' ').strip
  fn ? fn : org
end

#from_hcardObject

TODO proxy to parser



103
104
# File 'lib/visit_card/models/vcard.rb', line 103

def from_hcard()
end

#from_vcardObject

TODO



111
112
# File 'lib/visit_card/models/vcard.rb', line 111

def from_vcard()
end

#geoObject



46
47
48
49
# File 'lib/visit_card/models/vcard.rb', line 46

def geo
  result = "#{latitude};#{longitude}"
  result == ';' ? '' : result
end

#labelObject



51
52
53
# File 'lib/visit_card/models/vcard.rb', line 51

def label
  "#{fn}\n#{vcard_adrs.first.adr.squeeze(';').gsub(';','\n')}".strip
end

#nObject



38
39
40
# File 'lib/visit_card/models/vcard.rb', line 38

def n
  "#{family_name};#{given_name};#{additional_name};#{honorific_prefix};#{honorific_suffix}"
end

#orgObject



55
56
57
# File 'lib/visit_card/models/vcard.rb', line 55

def org
  organization_unit? ? "#{organization_name};#{organization_unit}" : organization_name
end

#revObject

TODO support two variants of category store - through habtm & simple string def category end



63
64
65
# File 'lib/visit_card/models/vcard.rb', line 63

def rev
  updated_at
end

#to_hcard(options = {}, &block) ⇒ Object

TODO refactor! template? TODO separate and improve geo, org TODO add photo, logo, tz, category, extensions



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/visit_card/models/vcard.rb', line 70

def to_hcard(options = {}, &block)
  result = []
  clasess = ['fn']
  clasess << 'org' if org == fn
  if url?
    clasess << 'url'
    result << "<a class='#{clasess.join(' ')}' href='#{url}'>#{fn}</a>"
  else
    result << "<span class='#{clasess.join(' ')}'>#{fn}</span>"
  end
  result << "(<span class='nickname'>#{nickname}</span>)" if nickname?
  result << "<abbr class='bday' title='#{bday.to_s}'>#{I18n.l(bday, :format => :long)}</abbr>" if bday?
  result << "<span class='title'>#{title}</span>" if title?
  result << "<span class='role'>#{role}</span>" if role?
  result << "<span class='org'>#{org}</span>" if org.present? && org != fn
  vcard_adrs.each do |adr|
    result << adr.to_hcard
  end
  result << "<abbr class='geo' title='#{geo}'>Location</abbr>" if geo.present?
  # result << "<span class='geo'><abbr class='latitude' title='#{latitude}'>N 48° 81.6667</abbr><abbr class='longitude' title='2.366667'>E 2° 36.6667</abbr></span>" if geo.present?
  vcard_tels.each do |tel|
    result << tel.to_hcard
  end
  vcard_emails.each do |email|
    result << email.to_hcard
  end
  # result.compact!
  result << agent.to_hcard if agent_id? # TODO add agent class?
  main_tag_name = options.fetch(:main_tag_name, 'div')
  ("<#{main_tag_name} class='vcard'>" << result.join(' ') << "</#{main_tag_name}>").html_safe          
end

#to_vcardObject

TODO



107
108
# File 'lib/visit_card/models/vcard.rb', line 107

def to_vcard
end