Class EimXML::PCString
In: lib/eim_xml.rb
Parent: Object

Methods

==   []   encode   new   write_to  

External Aliases

encoded_string -> to_s

Attributes

encoded_string  [R] 
src  [R] 

Public Class methods

[Source]

    # File lib/eim_xml.rb, line 31
31:                 def self.[](obj)
32:                         obj.is_a?(PCString) ? obj : PCString.new(obj)
33:                 end

[Source]

    # File lib/eim_xml.rb, line 14
14:                 def self.encode(s)
15:                         s.to_s.gsub(/[&\"\'<>]/) do |m|
16:                                 case m
17:                                 when "&"
18:                                         "&amp;"
19:                                 when '"'
20:                                         "&quot;"
21:                                 when "'"
22:                                         "&apos;"
23:                                 when "<"
24:                                         "&lt;"
25:                                 when ">"
26:                                         "&gt;"
27:                                 end
28:                         end
29:                 end

[Source]

    # File lib/eim_xml.rb, line 35
35:                 def initialize(s, encoded=false)
36:                         @src = s
37:                         @encoded_string = encoded ? s : PCString.encode(s)
38:                 end

Public Instance methods

[Source]

    # File lib/eim_xml.rb, line 40
40:                 def ==(other)
41:                         other.is_a?(PCString) ? @encoded_string==other.encoded_string : self==PCString.new(other)
42:                 end

[Source]

    # File lib/eim_xml.rb, line 44
44:                 def write_to(out="")
45:                         out << encoded_string
46:                 end

[Validate]