Class: LZMA::Utils::CRC32

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state = 0) ⇒ CRC32

Returns a new instance of CRC32.



22
23
24
25
# File 'lib/extlzma2/utils.rb', line 22

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



21
22
23
# File 'lib/extlzma2/utils.rb', line 21

def init
  @init
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



21
22
23
# File 'lib/extlzma2/utils.rb', line 21

def state
  @state
end

Instance Method Details

#digestObject



43
44
45
# File 'lib/extlzma2/utils.rb', line 43

def digest
  [state].pack('N')
end

#finishObject



34
35
36
# File 'lib/extlzma2/utils.rb', line 34

def finish
  self
end

#hexdigestObject Also known as: to_s



47
48
49
# File 'lib/extlzma2/utils.rb', line 47

def hexdigest
  format('%08x', state)
end

#resetObject



38
39
40
41
# File 'lib/extlzma2/utils.rb', line 38

def reset
  self.state = init
  self
end

#to_strObject Also known as: inspect



53
54
55
# File 'lib/extlzma2/utils.rb', line 53

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

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



27
28
29
30
# File 'lib/extlzma2/utils.rb', line 27

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