Class: Virginity::CustomImField

Inherits:
BaseField show all
Includes:
FieldValues::Text
Defined in:
lib/virginity/vcard/fields.rb

Overview

OS X AddressBook does not use the IMPP fields. Instead Apple chose to use their own proprietary format. This format is handles by CustomImField

Constant Summary collapse

PROTOCOL_TRANSLATION_TABLE =
{
  :aim => "X-AIM",
  :msn => "X-MSN",
  :ymsgr => "X-YAHOO",
  :skype => "X-SKYPE",
  :qq => "X-QQ",
  :gtalk => "X-GOOGLE TALK",
  :icq => "X-ICQ",
  :xmpp => "X-JABBER",
}
PROTOCOL_TRANSLATION_INVERSE_TABLE =
Hash[PROTOCOL_TRANSLATION_TABLE.map { |k, v| [v, k]

Constants inherited from BaseField

BaseField::BEGIN_REGEX, BaseField::END_REGEX, BaseField::PREF, BaseField::TYPE

Constants included from FieldCleaning

FieldCleaning::BOM_BINARY, FieldCleaning::BOM_UTF8, FieldCleaning::CASE_SENSITIVE_TYPES, FieldCleaning::CHARSET, FieldCleaning::ENCODING, FieldCleaning::LIST_NAMES, FieldCleaning::QUOTED_PRINTABLE, FieldCleaning::TYPE, FieldCleaning::X_SYNTHESIS_REF

Constants inherited from ContentLine

Virginity::ContentLine::COLON_CHAR, Virginity::ContentLine::GROUP, Virginity::ContentLine::GROUP_DELIMITER, Virginity::ContentLine::NAME

Instance Attribute Summary

Attributes inherited from ContentLine

#group, #name, #params, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FieldValues::Text

#reencode!, #text, #text=, #value_to_xml

Methods inherited from BaseField

#<=>, #==, [], #extra_fields_to_xml, #field_as_json, field_register, #group_and_params_as_json, merger, named, #params_to_xml, #params_to_xml!, parse, #pref?, #raw_value=, register_field, register_for, registered?, #to_xml, types, unregister, #value, #value=, #value_to_xml

Methods included from FieldCleaning

#clean!, #clean_base64!, #clean_binary_data!, #clean_charsets!, #clean_quoted_printable_encoding!, #clean_types!, #guess_latin!, #remove_bom!, #remove_encoding_8bit!, #remove_x_synthesis_ref_params!, #uniq_params!

Methods included from Vcard21::Writer

#encode21, #vcard21line

Methods inherited from ContentLine

#<=>, #==, #api_id, #encode, #eql?, #has_name?, #hash, #initialize, line_parts, #merge_with!, merger, #param_values, #params_to_s, parse, #pretty_print, #to_field

Methods included from Encodings

#binary?, #to_ascii, #to_binary, #to_default, #to_default!, #verify_utf8ness

Constructor Details

This class inherits a constructor from Virginity::ContentLine

Class Method Details

.from_impp(impp) ⇒ Object

convert a standard IMPP field to a Custom IM field. Only schemes defined in PROTOCOL_TRANSLATION_TABLE are supported.



104
105
106
107
108
109
110
111
# File 'lib/virginity/vcard/fields.rb', line 104

def self.from_impp(impp)
  nm = PROTOCOL_TRANSLATION_TABLE[impp.scheme.to_sym]
  raise "unknown scheme #{impp.scheme} for #{impp.text.inspect}" if nm.nil?
  x = Field.parse("#{nm}:")
  x.params = Param::deep_copy(impp.params)
  x.text = impp.address
  x
end

Instance Method Details

#protocolObject



113
114
115
# File 'lib/virginity/vcard/fields.rb', line 113

def protocol
  PROTOCOL_TRANSLATION_INVERSE_TABLE[name]
end

#to_imppObject

convert to a standard IMPP field



118
119
120
121
122
123
# File 'lib/virginity/vcard/fields.rb', line 118

def to_impp
  impp = Field.parse("IMPP:")
  impp.params = Param::deep_copy(@params)
  impp.text = "#{protocol}:#{text}"
  impp
end