Class: Vcard::V3_0::PropertyValue::Agent

Inherits:
Vobject::PropertyValue show all
Defined in:
lib/vobject/vcard/v3_0/propertyvalue.rb

Instance Attribute Summary

Attributes inherited from Vobject::PropertyValue

#errors, #norm, #type, #value

Instance Method Summary collapse

Methods inherited from Vobject::PropertyValue

#<=>, #name, #to_norm

Constructor Details

#initialize(val) ⇒ Agent

Returns a new instance of Agent.



371
372
373
374
375
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 371

def initialize(val)
  val[:VCARD].delete(:VERSION)
  self.value = val
  self.type = "agent"
end

Instance Method Details

#to_hashObject



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 377

def to_hash
  ret = {}
  value.each do |k, v|
    ret[k] = {}
    v.each do |k1, v1|
      if v1.is_a?(Hash)
        ret[k][k1] = {}
        v1.each { |k2, v2| ret[k][k1][k2] = v2.to_hash }
      else
        ret[k][k1] = v1
      end
    end
  end
  ret
end

#to_sObject



393
394
395
396
397
398
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 393

def to_s
  ret = Vobject::Component.new(:VCARD, value[:VCARD], []).to_s
  # spec says that colons must be expected, but none of the examples do
  ret.gsub(/\n/, "\\n").gsub(/,/, "\\,").gsub(/;/, "\\;")
  # ret.gsub(/\n/,"\\n").gsub(/:/,"\\:")
end