Class: Omnizip::Algorithms::LZMA::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/algorithms/lzma/match.rb

Overview

Match candidate result from LZ77 match finding

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(distance, length) ⇒ Match

Returns a new instance of Match.



10
11
12
13
# File 'lib/omnizip/algorithms/lzma/match.rb', line 10

def initialize(distance, length)
  @distance = distance
  @length = length
end

Instance Attribute Details

#distanceObject (readonly)

Returns the value of attribute distance.



8
9
10
# File 'lib/omnizip/algorithms/lzma/match.rb', line 8

def distance
  @distance
end

#lengthObject (readonly)

Returns the value of attribute length.



8
9
10
# File 'lib/omnizip/algorithms/lzma/match.rb', line 8

def length
  @length
end

Instance Method Details

#to_sString

String representation for debugging

Returns:

  • (String)

    Match description



26
27
28
# File 'lib/omnizip/algorithms/lzma/match.rb', line 26

def to_s
  "Match(dist=#{@distance}, len=#{@length})"
end

#valid?(dict_size) ⇒ Boolean

Check if match is valid for given dictionary size

Parameters:

  • dict_size (Integer)

    Dictionary size in bytes

Returns:

  • (Boolean)

    true if match is valid



19
20
21
# File 'lib/omnizip/algorithms/lzma/match.rb', line 19

def valid?(dict_size)
  @distance <= dict_size && @length >= 2
end