Class: CFPropertyList::CFString
- Defined in:
- lib/cfpropertylist/rbCFTypes.rb
Overview
This class holds string values, both, UTF-8 and UTF-16BE It will convert the value to UTF-16BE if necessary (i.e. if non-ascii char contained)
Instance Attribute Summary
Attributes inherited from CFType
Instance Method Summary collapse
- #quoted ⇒ Object
-
#to_binary(bplist) ⇒ Object
convert to binary.
- #to_plain(plist) ⇒ Object
-
#to_xml(parser) ⇒ Object
convert to XML.
Methods inherited from CFType
Constructor Details
This class inherits a constructor from CFPropertyList::CFType
Instance Method Details
#quoted ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cfpropertylist/rbCFTypes.rb', line 70 def quoted str = '"' @value.each_char do |c| str << case c when '"' '\\"' when '\\' '\\' when "\a" "\\a" when "\b" "\\b" when "\f" "\\f" when "\n" "\n" when "\v" "\\v" when "\r" "\\r" when "\t" "\\t" else c end end str << '"' end |
#to_binary(bplist) ⇒ Object
convert to binary
58 59 60 |
# File 'lib/cfpropertylist/rbCFTypes.rb', line 58 def to_binary(bplist) bplist.string_to_binary(@value); end |
#to_plain(plist) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/cfpropertylist/rbCFTypes.rb', line 62 def to_plain(plist) if @value =~ /^\w+$/ @value else quoted end end |
#to_xml(parser) ⇒ Object
convert to XML
51 52 53 54 55 |
# File 'lib/cfpropertylist/rbCFTypes.rb', line 51 def to_xml(parser) n = parser.new_node('string') n = parser.append_node(n, parser.new_text(@value)) unless @value.nil? n end |