Class: EimXML::PCString
- Inherits:
-
Object
- Object
- EimXML::PCString
- Defined in:
- lib/eim_xml.rb
Instance Attribute Summary collapse
-
#encoded_string ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute encoded_string.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(s, encoded = false) ⇒ PCString
constructor
A new instance of PCString.
- #write_to(out = "") ⇒ Object
Constructor Details
Instance Attribute Details
#encoded_string ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute encoded_string.
11 12 13 |
# File 'lib/eim_xml.rb', line 11 def encoded_string @encoded_string end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
11 12 13 |
# File 'lib/eim_xml.rb', line 11 def src @src end |
Class Method Details
.[](obj) ⇒ Object
31 32 33 |
# File 'lib/eim_xml.rb', line 31 def self.[](obj) obj.is_a?(PCString) ? obj : PCString.new(obj) end |
.encode(s) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/eim_xml.rb', line 14 def self.encode(s) s.to_s.gsub(/[&\"\'<>]/) do |m| case m when "&" "&" when '"' """ when "'" "'" when "<" "<" when ">" ">" end end end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 |
# File 'lib/eim_xml.rb', line 40 def ==(other) other.is_a?(PCString) ? @encoded_string==other.encoded_string : self==PCString.new(other) end |
#write_to(out = "") ⇒ Object
44 45 46 |
# File 'lib/eim_xml.rb', line 44 def write_to(out="") out << encoded_string end |