Class: SimpleVpim

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

Defined Under Namespace

Classes: Contact, Event

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rawobj, debug: false) ⇒ SimpleVpim

Returns a new instance of SimpleVpim.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/simplevpim.rb', line 22

def initialize(rawobj, debug: false)
  
  @debug = debug

  obj = if block_given? then
    
    if rawobj == :event then
              
      e = Event.new
      yield e
      e.to_h
      
    elsif rawobj == :contact then

      puts 'inside contact' if @debug
      c = Contact.new
      yield c
      c.to_h        
      
    end
    
  else
    
    rawobj
    
  end
  
  puts 'obj: ' + obj.inspect if @debug
  
  kvx = Kvx.new(obj, debug: false)
  
  @h = kvx.to_h

  if @h[:name] or @h[:firstname] or @h[:lastname] then
    
    @to_vcard = make_vcard @h
    @to_xml = vcard_xml @h      
    
  elsif @h[:start]
    
    @to_vevent = make_vevent @h
    @to_xml = vevent_xml kvx.to_xml
    
  end

end

Instance Attribute Details

#to_vcardObject (readonly) Also known as: to_vcf

Returns the value of attribute to_vcard.



16
17
18
# File 'lib/simplevpim.rb', line 16

def to_vcard
  @to_vcard
end

#to_veventObject (readonly)

Returns the value of attribute to_vevent.



16
17
18
# File 'lib/simplevpim.rb', line 16

def to_vevent
  @to_vevent
end

#to_xmlObject (readonly)

Returns the value of attribute to_xml.



16
17
18
# File 'lib/simplevpim.rb', line 16

def to_xml
  @to_xml
end

Instance Method Details

#to_hcard(layout = nil) ⇒ Object



71
72
73
# File 'lib/simplevpim.rb', line 71

def to_hcard(layout=nil)
  make_hcard layout, @h
end

#to_xcardObject



75
76
77
# File 'lib/simplevpim.rb', line 75

def to_xcard()
  make_xcard @to_xml    
end