Class: Vpim::Vcard::Name
- Inherits:
-
Object
- Object
- Vpim::Vcard::Name
- Defined in:
- lib/vpim/vcard.rb
Overview
The name from a vCard, including all the components of the N: and FN: fields.
Instance Attribute Summary collapse
-
#additional ⇒ Object
additional names, from N.
-
#family ⇒ Object
family name, from N.
-
#formatted ⇒ Object
readonly
:nodoc:.
-
#fullname ⇒ Object
full name, the FN field.
-
#given ⇒ Object
given name, from N.
-
#prefix ⇒ Object
such as “Ms.” or “Dr.”, from N.
-
#suffix ⇒ Object
such as “BFA”, from N.
Instance Method Summary collapse
-
#encode ⇒ Object
:nodoc:.
-
#encode_fn ⇒ Object
:nodoc:.
-
#initialize(n = '', fn = '') ⇒ Name
constructor
:nodoc:.
Constructor Details
#initialize(n = '', fn = '') ⇒ Name
:nodoc:
397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/vpim/vcard.rb', line 397 def initialize(n='', fn='') #:nodoc: n = Vpim.decode_text_list(n, ';') do |item| item.strip end @family = n[0] || "" @given = n[1] || "" @additional = n[2] || "" @prefix = n[3] || "" @suffix = n[4] || "" # FIXME - make calls to #fullname fail if fn is nil @fullname = (fn || "").strip end |
Instance Attribute Details
#additional ⇒ Object
additional names, from N
375 376 377 |
# File 'lib/vpim/vcard.rb', line 375 def additional @additional end |
#family ⇒ Object
family name, from N
371 372 373 |
# File 'lib/vpim/vcard.rb', line 371 def family @family end |
#formatted ⇒ Object (readonly)
:nodoc:
385 386 387 |
# File 'lib/vpim/vcard.rb', line 385 def formatted @formatted end |
#fullname ⇒ Object
full name, the FN field. FN is a formatted version of the N field, intended to be in a form more aligned with the cultural conventions of the vCard owner than formatted is.
383 384 385 |
# File 'lib/vpim/vcard.rb', line 383 def fullname @fullname end |
#given ⇒ Object
given name, from N
373 374 375 |
# File 'lib/vpim/vcard.rb', line 373 def given @given end |
#prefix ⇒ Object
such as “Ms.” or “Dr.”, from N
377 378 379 |
# File 'lib/vpim/vcard.rb', line 377 def prefix @prefix end |
#suffix ⇒ Object
such as “BFA”, from N
379 380 381 |
# File 'lib/vpim/vcard.rb', line 379 def suffix @suffix end |
Instance Method Details
#encode ⇒ Object
:nodoc:
412 413 414 415 416 |
# File 'lib/vpim/vcard.rb', line 412 def encode #:nodoc: Vpim::DirectoryInfo::Field.create('N', Vpim.encode_text_list([ @family, @given, @additional, @prefix, @suffix ].map{|n| n.strip}, ';') ) end |
#encode_fn ⇒ Object
:nodoc:
417 418 419 420 421 422 423 |
# File 'lib/vpim/vcard.rb', line 417 def encode_fn #:nodoc: fn = @fullname.strip if @fullname.length == 0 fn = formatted end Vpim::DirectoryInfo::Field.create('FN', fn) end |