Class: RunLengthEncodingRb::Encoder

Inherits:
Object
  • Object
show all
Defined in:
lib/run_length_encoding_rb/encoder.rb

Overview

Encode data with RLE.

Instance Method Summary collapse

Instance Method Details

#encode(data, separator = "") ⇒ Array<::RLEElement>

Encode an array with the run-length encoding.

Parameters:

  • data (Array, String, Enumerator)

    Data to encode.

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<::RLEElement>)

    Encoded data.



20
21
22
23
24
25
26
# File 'lib/run_length_encoding_rb/encoder.rb', line 20

def encode(data, separator = "")
  array = _to_array(data, separator)

  _raise_on_unsupported_type(data.class) unless array

  _encode(array)
end