Class: RSpec::Support::EncodedString
- Inherits:
-
Object
- Object
- RSpec::Support::EncodedString
- Defined in:
- lib/rspec/support/encoded_string.rb
Constant Summary collapse
- MRI_UNICODE_UNKOWN_CHARACTER =
"\xEF\xBF\xBD"
Instance Attribute Summary collapse
-
#source_encoding ⇒ Object
readonly
Returns the value of attribute source_encoding.
Instance Method Summary collapse
- #<<(string) ⇒ Object
-
#initialize(string, encoding = nil) ⇒ EncodedString
constructor
A new instance of EncodedString.
- #split(regex_or_string) ⇒ Object
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize(string, encoding = nil) ⇒ EncodedString
Returns a new instance of EncodedString.
8 9 10 11 12 |
# File 'lib/rspec/support/encoded_string.rb', line 8 def initialize(string, encoding = nil) @encoding = encoding @source_encoding = detect_source_encoding(string) @string = matching_encoding(string) end |
Instance Attribute Details
#source_encoding ⇒ Object (readonly)
Returns the value of attribute source_encoding.
13 14 15 |
# File 'lib/rspec/support/encoded_string.rb', line 13 def source_encoding @source_encoding end |
Instance Method Details
#<<(string) ⇒ Object
20 21 22 |
# File 'lib/rspec/support/encoded_string.rb', line 20 def <<(string) @string << matching_encoding(string) end |
#split(regex_or_string) ⇒ Object
24 25 26 |
# File 'lib/rspec/support/encoded_string.rb', line 24 def split(regex_or_string) @string.split(matching_encoding(regex_or_string)) end |
#to_s ⇒ Object Also known as: to_str
28 29 30 |
# File 'lib/rspec/support/encoded_string.rb', line 28 def to_s @string end |