Method: Vpim::DirectoryInfo.decode
- Defined in:
- lib/vpim/dirinfo.rb
.decode(card) ⇒ Object
Decode card
into a DirectoryInfo object.
card
may either be a something that is convertible to a string using #to_str or an Array of objects that can be joined into a string using #join(“n”), or an IO object (which will be read to end-of-file).
The lines in the string may be delimited using IETF (CRLF) or Unix (LF) conventions.
A DirectoryInfo is mutable, you can add new fields to it, see Vpim::DirectoryInfo::Field#create() for how to create a new Field.
TODO: I don’t believe this is ever used, maybe I can remove it.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vpim/dirinfo.rb', line 64 def DirectoryInfo.decode(card) #:nodoc: if card.respond_to? :to_str string = card.to_str elsif card.kind_of? Array string = card.join("\n") elsif card.kind_of? IO string = card.read(nil) else raise ArgumentError, "DirectoryInfo cannot be created from a #{card.type}" end fields = Vpim.decode(string) new(fields) end |