Class: LZMA::Utils::CRC32

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

Overview

CRC32 を Digest のように生成できるようになります。

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state = 0) ⇒ CRC32

Returns a new instance of CRC32.



394
395
396
397
# File 'lib/extlzma.rb', line 394

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



393
394
395
# File 'lib/extlzma.rb', line 393

def init
  @init
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



393
394
395
# File 'lib/extlzma.rb', line 393

def state
  @state
end

Instance Method Details

#digestObject



419
420
421
# File 'lib/extlzma.rb', line 419

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

#finishObject



410
411
412
# File 'lib/extlzma.rb', line 410

def finish
  self
end

#hexdigestObject Also known as: to_s



423
424
425
# File 'lib/extlzma.rb', line 423

def hexdigest
  "%08x" % state
end

#resetObject



414
415
416
417
# File 'lib/extlzma.rb', line 414

def reset
  self.state = init
  self
end

#to_strObject Also known as: inspect



429
430
431
# File 'lib/extlzma.rb', line 429

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

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

call-seq:

LZMA::Utils::CRC32#update(data) -> self


403
404
405
406
# File 'lib/extlzma.rb', line 403

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