Class: Vcard
- Inherits:
-
Vobject::Component
- Object
- Vobject::Component
- Vcard
- Defined in:
- lib/vcard.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#version ⇒ Object
Returns the value of attribute version.
Attributes inherited from Vobject::Component
#children, #comp_name, #errors, #multiple_components, #norm
Class Method Summary collapse
- .blank(version) ⇒ Object
- .decode(vcard_str, version = nil) ⇒ Object
- .parse(vcf, version, strict) ⇒ Object
Instance Method Summary collapse
-
#initialize(version) ⇒ Vcard
constructor
A new instance of Vcard.
Methods inherited from Vobject::Component
#<=>, #blank, #child_class, #get_errors, #to_hash, #to_json, #to_norm, #to_s
Constructor Details
#initialize(version) ⇒ Vcard
Returns a new instance of Vcard.
31 32 33 34 |
# File 'lib/vcard.rb', line 31 def initialize(version) self.version = version super VCARD: { VERSION: { value: version } } end |
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/vcard.rb', line 5 def version @version end |
Class Method Details
.blank(version) ⇒ Object
8 9 10 |
# File 'lib/vcard.rb', line 8 def blank(version) new VERSION: { value: version } end |
.decode(vcard_str, version = nil) ⇒ Object
12 13 14 15 |
# File 'lib/vcard.rb', line 12 def decode(vcard_str, version = nil) version_str = version.nil? ? "4.0" : /\nVERSION:([^\n\r]+)/i.match(vcard_str)[1] blank(version_str).parse(vcard_str) end |
.parse(vcf, version, strict) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/vcard.rb', line 17 def parse(vcf, version, strict) hash = version == "3.0" ? Vcard::V3_0::Component.parse(vcf, strict) : Vcard::V4_0::Component.parse(vcf, strict) # comp_name = hash.keys.first # return self.new(comp_name, hash[:vobject][comp_name], hash[:errors] ) hash end |