Class: Multibases::DecodedByteArray
Instance Method Summary
collapse
Methods inherited from ByteArray
#hash, #initialize, #is_a?, #to_arr, #transcode
Instance Method Details
#inspect ⇒ Object
72
73
74
75
|
# File 'lib/multibases/byte_array.rb', line 72
def inspect
encoding = @encoding || Encoding::BINARY
"[Multibases::DecodedByteArray \"#{to_str(encoding)}\"]"
end
|
#to_ascii_str ⇒ Object
83
84
85
|
# File 'lib/multibases/byte_array.rb', line 83
def to_ascii_str
to_str(Encoding::US_ASCII)
end
|
#to_str(encoding = @encoding) ⇒ Object
Also known as:
to_s
77
78
79
80
81
|
# File 'lib/multibases/byte_array.rb', line 77
def to_str(encoding = @encoding)
raise MissingEncoding unless encoding
pack('C*').force_encoding(encoding)
end
|
#to_utf8_str ⇒ Object
87
88
89
|
# File 'lib/multibases/byte_array.rb', line 87
def to_utf8_str
to_str(Encoding::UTF_8)
end
|