def value(name, type = nil)
      fields = enum_by_name(name).find_all { |f| type == nil || f.type?(type) }

      valued = fields.select { |f| f.value != "" }
      if valued.first
        fields = valued
      end

      pref = fields.select { |f| f.pref? }

      if pref.first
        fields = pref
      end

      if fields.first
        line = begin
                 Line.decode(@@decode, self, fields.first)
               rescue ::Vcard::InvalidEncodingError
               end

        if line
          return line.value
        end
      end

      nil
    end
def value(name, type = nil)
      fields = enum_by_name(name).find_all { |f| type == nil || f.type?(type) }

      valued = fields.select { |f| f.value != "" }
      if valued.first
        fields = valued
      end

      pref = fields.select { |f| f.pref? }

      if pref.first
        fields = pref
      end

      if fields.first
        line = begin
                 Line.decode(@@decode, self, fields.first)
               rescue ::Vcard::InvalidEncodingError
               end

        if line
          return line.value
        end
      end

      nil
    end
Return the Line#value for a specific +name+, and optionally for a
 specific +type+.

 If no line with the +name+ (and, optionally, +type+) exists, nil is
 returned.

 If multiple lines exist, the order of preference is:
 - lines with values over lines without
 - lines with a type of "pref" over lines without
 If multiple lines are equally preferred, then the first line will be
 returned.

 This is most useful when looking for a line that can not occur multiple
 times, or when the line can occur multiple times, and you want to pick
 the first preferred line of a specific type. See #values if you need to
 access all the lines.

 Note that the +type+ field parameter is used for different purposes by
 the various kinds of vCard lines, but for the addressing lines (ADR,
 LABEL, TEL, EMAIL) it is has a reasonably consistent usage. Each
 addressing line can occur multiple times, and a +type+ of "pref"
 indicates that a particular line is the preferred line. Other +type+
 values tend to indicate some information about the location ("home",
 "work", ...) or some detail about the address ("cell", "fax", "voice",
 ...). See the methods for the specific types of line for information
 about supported types and their meaning.