Class: EimXML::PCString
- Inherits:
-
Object
- Object
- EimXML::PCString
- Defined in:
- lib/eim_xml.rb
Constant Summary collapse
- ENCODING_MAP =
{ '&' => '&', '"' => '"', "'" => ''', '<' => '<', '>' => '>' }
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(src, encoded = false) ⇒ PCString
constructor
rubocop:disable Style/OptionalBooleanParameter.
- #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
28 29 30 |
# File 'lib/eim_xml.rb', line 28 def self.[](obj) obj.is_a?(PCString) ? obj : PCString.new(obj) end |
.encode(src) ⇒ Object
22 23 24 25 26 |
# File 'lib/eim_xml.rb', line 22 def self.encode(src) src.to_s.gsub(/[&"'<>]/) do |m| ENCODING_MAP[m] end end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 |
# File 'lib/eim_xml.rb', line 37 def ==(other) other.is_a?(PCString) ? @encoded_string == other.encoded_string : self == PCString.new(other) end |
#write_to(out = '') ⇒ Object
41 42 43 |
# File 'lib/eim_xml.rb', line 41 def write_to(out = '') out << encoded_string end |