Class: Multibases::Encoded

Inherits:
Struct
  • Object
show all
Defined in:
lib/multibases/bare.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



9
10
11
# File 'lib/multibases/bare.rb', line 9

def code
  @code
end

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



9
10
11
# File 'lib/multibases/bare.rb', line 9

def data
  @data
end

#encodingObject

Returns the value of attribute encoding

Returns:

  • (Object)

    the current value of encoding



9
10
11
# File 'lib/multibases/bare.rb', line 9

def encoding
  @encoding
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of 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

Returns:

Raises:



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

#packEncodedByteArray

Packs the data and the code into an encoded string

Returns:



15
16
17
18
# File 'lib/multibases/bare.rb', line 15

def pack
  data.unshift(code.ord)
  data
end