Class: Lz4rip::Dictionary
- Inherits:
-
Data
- Object
- Data
- Lz4rip::Dictionary
- Defined in:
- lib/lz4rip/dictionary.rb
Overview
Immutable LZ4 dictionary value.
Instance Attribute Summary collapse
-
#bytes ⇒ String
readonly
Frozen binary dictionary bytes.
-
#id ⇒ Integer
readonly
Dictionary ID.
Instance Method Summary collapse
-
#initialize(bytes:, id: Digest::SHA256.digest(bytes).byteslice(0, 4).unpack1("V")) ⇒ Dictionary
constructor
A new instance of Dictionary.
-
#size ⇒ Integer
Dictionary size in bytes.
Constructor Details
#initialize(bytes:, id: Digest::SHA256.digest(bytes).byteslice(0, 4).unpack1("V")) ⇒ Dictionary
Returns a new instance of Dictionary.
16 17 18 |
# File 'lib/lz4rip/dictionary.rb', line 16 def initialize(bytes:, id: Digest::SHA256.digest(bytes).byteslice(0, 4).unpack1("V")) super(bytes: bytes.b.freeze, id: id) end |
Instance Attribute Details
#bytes ⇒ String (readonly)
Returns frozen binary dictionary bytes.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lz4rip/dictionary.rb', line 13 Dictionary = Data.define(:bytes, :id) do # @param bytes [String] dictionary bytes # @param id [Integer] optional dictionary ID def initialize(bytes:, id: Digest::SHA256.digest(bytes).byteslice(0, 4).unpack1("V")) super(bytes: bytes.b.freeze, id: id) end # @return [Integer] dictionary size in bytes def size bytes.bytesize end end |
#id ⇒ Integer (readonly)
Returns dictionary ID.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lz4rip/dictionary.rb', line 13 Dictionary = Data.define(:bytes, :id) do # @param bytes [String] dictionary bytes # @param id [Integer] optional dictionary ID def initialize(bytes:, id: Digest::SHA256.digest(bytes).byteslice(0, 4).unpack1("V")) super(bytes: bytes.b.freeze, id: id) end # @return [Integer] dictionary size in bytes def size bytes.bytesize end end |
Instance Method Details
#size ⇒ Integer
Returns dictionary size in bytes.
22 23 24 |
# File 'lib/lz4rip/dictionary.rb', line 22 def size bytes.bytesize end |