Class: Multibases::Encoded
- Inherits:
-
Struct
- Object
- Struct
- Multibases::Encoded
- Defined in:
- lib/multibases/bare.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#data ⇒ Object
Returns the value of attribute data.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#length ⇒ Object
Returns the value of attribute length.
Instance Method Summary collapse
-
#decode(engine = Multibases.engine(encoding)) ⇒ DecodedByteArray
Decodes the data and returns a DecodedByteArray.
-
#pack ⇒ EncodedByteArray
Packs the data and the code into an encoded string.
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
9 10 11 |
# File 'lib/multibases/bare.rb', line 9 def code @code end |
#data ⇒ Object
Returns the value of attribute data
9 10 11 |
# File 'lib/multibases/bare.rb', line 9 def data @data end |
#encoding ⇒ Object
Returns the value of attribute encoding
9 10 11 |
# File 'lib/multibases/bare.rb', line 9 def encoding @encoding end |
#length ⇒ Object
Returns the value of attribute length
9 10 11 |
# File 'lib/multibases/bare.rb', line 9 def length @length end |
Instance Method Details
#decode(engine = Multibases.engine(encoding)) ⇒ DecodedByteArray
Decodes the data and returns a DecodedByteArray
25 26 27 28 29 |
# File 'lib/multibases/bare.rb', line 25 def decode(engine = Multibases.engine(encoding)) raise NoEngine, encoding unless engine engine.decode(data) end |
#pack ⇒ EncodedByteArray
Packs the data and the code into an encoded string
15 16 17 18 |
# File 'lib/multibases/bare.rb', line 15 def pack data.unshift(code.ord) data end |