Method: Vpim::Vcard::Maker#name

Defined in:
lib/vpim/vcard.rb

#name {|x| ... } ⇒ Object Also known as: add_name

Set the name fields, N and FN.

Attributes of name are:

  • family: family name

  • given: given name

  • additional: additional names

  • prefix: such as “Ms.” or “Dr.”

  • suffix: such as “BFA”, or “Sensei”

name is a Vcard::Name.

All attributes are optional, though have all names be zero-length strings isn’t really in the spirit of things. FN’s value will be set to Vcard::Name#formatted if Vcard::Name#fullname isn’t given a specific value.

Warning: This is the only mandatory field.

Yields:

  • (x)


1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
# File 'lib/vpim/vcard.rb', line 1130

def name #:yield:name
  x = begin
        @card.name.dup
      rescue
        Vpim::Vcard::Name.new
      end

  fn = x.fullname

  yield x

  x.fullname.strip!

  delete_if do |line|
    line.name == 'N'
  end

  @card << x.encode
  @card << x.encode_fn

  self
end