Class: Contacts::Vcf
Instance Method Summary collapse
- #contacts ⇒ Object
-
#initialize(file) ⇒ Vcf
constructor
A new instance of Vcf.
Methods inherited from Base
#connect, #connected?, #login, #password, #skip_gzip?
Constructor Details
#initialize(file) ⇒ Vcf
Returns a new instance of Vcf.
4 5 6 |
# File 'lib/contacts/vcf.rb', line 4 def initialize(file) @contact_file = file end |
Instance Method Details
#contacts ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/contacts/vcf.rb', line 8 def contacts contacts = Array.new i = 0 @contact_file.each do |line| contacts[i] = Array.new unless contacts[i] if line.match(/FN:/) contacts[i] << line.gsub(/FN:/, '').strip elsif line.match(/EMAIL;/) contacts[i] << line.gsub(/^.*:/, '').strip elsif line.match(/END:VCARD/) i += 1 end end contacts end |