Class: Virginity::DirectoryInformation
- Inherits:
-
Object
- Object
- Virginity::DirectoryInformation
- Extended by:
- Encodings, Vcard21::Reader
- Includes:
- Query
- Defined in:
- lib/virginity/dir_info.rb
Overview
see rfc 2425, MIME Content-Type for Directory Information.
Basically a DirectoryInformation-object is a collection of lines (see ContentLine)
Direct Known Subclasses
Constant Summary collapse
- LF =
string representation that is not folded (see LineFolding)
"\n"
Constants included from Vcard21::Reader
Vcard21::Reader::LATIN1, Vcard21::Reader::UNSUPPORTED_CONTROL_CHARS
Constants included from Query
Query::COLON, Query::COMMA, Query::EQUALS, Query::GROUP, Query::KEY, Query::NAME, Query::PARAM_NAME, Query::PARAM_VALUE, Query::SEMICOLON
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
Instance Method Summary collapse
-
#<<(line) ⇒ Object
(also: #push)
append a line.
-
#==(other) ⇒ Object
equallity is defined as having the same lines.
- #delete(*lines_to_delete) ⇒ Object
-
#delete_content_line(cl) ⇒ Object
remove only this exact content line identified by its object-id.
-
#encode ⇒ Object
(also: #to_s)
string representation.
-
#eql?(other) ⇒ Boolean
eql? is defined as being of the same class (not a descendent class like Vcard) and having the same lines.
-
#initialize(string = "") ⇒ DirectoryInformation
constructor
decode directory information text TODO accept an array of lines as the argument, make a special from_string(string=“”).
- #inspect ⇒ Object
- #pretty_print(q) ⇒ Object
-
#subset_of?(other) ⇒ Boolean
are all @lines also present in other?.
- #superset_of?(other) ⇒ Boolean
- #unfolded ⇒ Object
Methods included from Vcard21::Reader
convert_base64_to_b!, convert_charsets!, fix_vcard21_line!, from_vcard21, guess_charset!, guess_charset_for_part!, line21_parts, lines_from_vcard21, read_21_line, reencode_quoted_printable!
Methods included from Encodings
binary?, to_ascii, to_binary, to_default, to_default!, verify_utf8ness
Methods included from Query
decode_query, #find_first, #first_match, #line_matches_query?, #lines_with_name, params, #query, #where
Constructor Details
#initialize(string = "") ⇒ DirectoryInformation
decode directory information text TODO accept an array of lines as the argument, make a special from_string(string=“”)
23 24 25 26 27 28 |
# File 'lib/virginity/dir_info.rb', line 23 def initialize(string = "") raise "expected a string but found #{string.inspect}, a #{string.class}" unless string.is_a? String @lines = LineFolding::unfold_and_split(string).map do |line| ContentLine.parse(line) end end |
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
19 20 21 |
# File 'lib/virginity/dir_info.rb', line 19 def lines @lines end |
Instance Method Details
#<<(line) ⇒ Object Also known as: push
append a line
55 56 57 |
# File 'lib/virginity/dir_info.rb', line 55 def <<(line) lines << ContentLine.parse(line.to_s) end |
#==(other) ⇒ Object
equallity is defined as having the same lines
71 72 73 74 75 |
# File 'lib/virginity/dir_info.rb', line 71 def ==(other) return false if other.class != self.class # checking for lines.size is an optimisation @lines.size == other.lines.size and @lines.sort == other.lines.sort end |
#delete(*lines_to_delete) ⇒ Object
45 46 47 |
# File 'lib/virginity/dir_info.rb', line 45 def delete(*lines_to_delete) lines_to_delete.compact.map { |line| lines.delete(line) }.compact end |
#delete_content_line(cl) ⇒ Object
remove only this exact content line identified by its object-id
50 51 52 |
# File 'lib/virginity/dir_info.rb', line 50 def delete_content_line(cl) lines.delete_if { |line| line.object_id == cl.object_id } end |
#encode ⇒ Object Also known as: to_s
string representation
31 32 33 |
# File 'lib/virginity/dir_info.rb', line 31 def encode LineFolding::fold(unfolded) end |
#eql?(other) ⇒ Boolean
eql? is defined as being of the same class (not a descendent class like Vcard) and having the same lines
78 79 80 |
# File 'lib/virginity/dir_info.rb', line 78 def eql?(other) self.class == other.class and self == other end |
#inspect ⇒ Object
41 42 43 |
# File 'lib/virginity/dir_info.rb', line 41 def inspect "#<#{self.class}:#{object_id}>" end |
#pretty_print(q) ⇒ Object
66 67 68 |
# File 'lib/virginity/dir_info.rb', line 66 def pretty_print(q) q.text unfolded end |
#subset_of?(other) ⇒ Boolean
are all @lines also present in other?
83 84 85 86 87 |
# File 'lib/virginity/dir_info.rb', line 83 def subset_of?(other) @lines.all? do |line| other.first_match(line.to_s) end end |
#superset_of?(other) ⇒ Boolean
89 90 91 |
# File 'lib/virginity/dir_info.rb', line 89 def superset_of?(other) other.subset_of?(self) end |