Class: LZMA::Utils::CRC64

Inherits:
Struct
  • Object
show all
Defined in:
lib/extlzma2/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state = 0) ⇒ CRC64

Returns a new instance of CRC64.



61
62
63
64
# File 'lib/extlzma2/utils.rb', line 61

def initialize(state = 0)
  state = state.to_i
  super(state, state)
end

Instance Attribute Details

#initObject

Returns the value of attribute init

Returns:

  • (Object)

    the current value of init



60
61
62
# File 'lib/extlzma2/utils.rb', line 60

def init
  @init
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



60
61
62
# File 'lib/extlzma2/utils.rb', line 60

def state
  @state
end

Instance Method Details

#digestObject



82
83
84
# File 'lib/extlzma2/utils.rb', line 82

def digest
  [state].pack('Q>')
end

#finishObject



73
74
75
# File 'lib/extlzma2/utils.rb', line 73

def finish
  self
end

#hexdigestObject Also known as: to_s



86
87
88
# File 'lib/extlzma2/utils.rb', line 86

def hexdigest
  '%016x' % state
end

#resetObject



77
78
79
80
# File 'lib/extlzma2/utils.rb', line 77

def reset
  self.state = init
  self
end

#to_strObject Also known as: inspect



92
93
94
# File 'lib/extlzma2/utils.rb', line 92

def to_str
  "CRC64 <#{hexdigest}>"
end

#update(data) ⇒ Object Also known as: <<



66
67
68
69
# File 'lib/extlzma2/utils.rb', line 66

def update(data)
  self.state = Utils.crc64(data, state)
  self
end