Sha256: d5cdd9dffb0b1af8e16808a0728c368f7492921093e2524aacf58b0d00376e34

Contents?: true

Size: 634 Bytes

Versions: 1

Compression:

Stored size: 634 Bytes

Contents

require 'rbkb/cli'

# Copyright 2009 emonti at matasano.com 
# See README.rdoc for license information
#
# crc32 returns a crc32 checksum in hex from stdin or a file
class Rbkb::Cli::Crc32 < Rbkb::Cli::Executable
  def initialize(*args)
    super(*args)
    @opts[:first] ||= 0
    @opts[:last]  ||= -1
  end

  def make_parser()
    super()
    add_std_file_opt(:indat)
    add_range_opts(:first, :last)
  end

  def parse(*args)
    super(*args)
    parse_catchall()
  end

  def go(*args)
    super(*args)
    @opts[:indat] ||= @stdin.read()
    @stdout.puts @opts[:indat][ @opts[:first] .. @opts[:last] ].crc32.to_hex
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emonti-rbkb-0.6.2.1 lib/rbkb/cli/crc32.rb