Class: MiniSpec::Differ::EncodedString
- Inherits:
-
Object
- Object
- MiniSpec::Differ::EncodedString
- Defined in:
- lib/minispec/utils/differ.rb
Constant Summary collapse
- MRI_UNICODE_UNKNOWN_CHARACTER =
"\xEF\xBF\xBD".freeze
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.
32 33 34 35 36 |
# File 'lib/minispec/utils/differ.rb', line 32 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.
37 38 39 |
# File 'lib/minispec/utils/differ.rb', line 37 def source_encoding @source_encoding end |
Instance Method Details
#<<(string) ⇒ Object
44 45 46 |
# File 'lib/minispec/utils/differ.rb', line 44 def <<(string) @string << matching_encoding(string) end |
#split(regex_or_string) ⇒ Object
48 49 50 |
# File 'lib/minispec/utils/differ.rb', line 48 def split(regex_or_string) @string.split(matching_encoding(regex_or_string)) end |
#to_s ⇒ Object Also known as: to_str
52 53 54 |
# File 'lib/minispec/utils/differ.rb', line 52 def to_s @string end |