Sha256: ce6844dd581b75f78000a3f6fe6db678725a74280b23aa3b1c33ebc4f015a084
Contents?: true
Size: 1.65 KB
Versions: 6
Compression:
Stored size: 1.65 KB
Contents
require "vobject" require "vobject/component" class Vcard < Vobject::Component attr_accessor :version class << self def blank(version) new VERSION: { value: version } end 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 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 private def raise_invalid_parsing raise "vCard parse failed" end end def initialize(version) self.version = version super VCARD: { VERSION: { value: version } } end private def name :VCARD end def property_base_class version == "3.0" ? Vcard::V3_0::Property : Vcard::V4_0::Property # version_class.const_get(:Property) end def component_base_class version == "3.0" ? Vcard::V3_0::Component : Vcard::V4_0::Component # version_class.const_get(:Component) end end def require_dir(dir) base = File.expand_path("../", __FILE__) Dir.glob(File.join(base, dir, "**", "*.rb")).each do |path| require path.gsub(/\.rb\Z/, "") end end require "vobject/vcard/v4_0/component" require "vobject/vcard/v4_0/property" require_dir "vobject/vcard/v4_0/component" require_dir "vobject/vcard/v4_0/property" require "vobject/vcard/v3_0/component" require "vobject/vcard/v3_0/property" require_dir "vobject/vcard/v3_0/component" require_dir "vobject/vcard/v3_0/property"
Version data entries
6 entries across 6 versions & 2 rubygems