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.
17 18 19 |
# File 'lib/eim_xml.rb', line 17 def encoded_string @encoded_string end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
17 18 19 |
# File 'lib/eim_xml.rb', line 17 def src @src end |
Class Method Details
.[](obj) ⇒ Object
37 38 39 |
# File 'lib/eim_xml.rb', line 37 def self.[](obj) obj.is_a?(PCString) ? obj : PCString.new(obj) end |
.encode(s) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eim_xml.rb', line 20 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
46 47 48 |
# File 'lib/eim_xml.rb', line 46 def ==(other) other.is_a?(PCString) ? @encoded_string==other.encoded_string : self==PCString.new(other) end |
#write_to(out = "") ⇒ Object
50 51 52 |
# File 'lib/eim_xml.rb', line 50 def write_to(out="") out << encoded_string end |