Class: LZMA::Utils::CRC64

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state = 0) ⇒ CRC64

Returns a new instance of CRC64.



440
441
442
443
# File 'lib/extlzma.rb', line 440

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



439
440
441
# File 'lib/extlzma.rb', line 439

def init
  @init
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



439
440
441
# File 'lib/extlzma.rb', line 439

def state
  @state
end

Instance Method Details

#digestObject



465
466
467
# File 'lib/extlzma.rb', line 465

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

#finishObject



456
457
458
# File 'lib/extlzma.rb', line 456

def finish
  self
end

#hexdigestObject Also known as: to_s



469
470
471
# File 'lib/extlzma.rb', line 469

def hexdigest
  "%016x" % state
end

#resetObject



460
461
462
463
# File 'lib/extlzma.rb', line 460

def reset
  self.state = init
  self
end

#to_strObject Also known as: inspect



475
476
477
# File 'lib/extlzma.rb', line 475

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

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

call-seq:

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


449
450
451
452
# File 'lib/extlzma.rb', line 449

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