class Rbkb::Cli::Crc32
Copyright 2009 emonti at matasano.com See README.rdoc for license information
crc32 returns a crc32 checksum in hex from stdin or a file
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
Rbkb::Cli::Executable::new
# File lib/rbkb/cli/crc32.rb, line 8 def initialize(*args) super(*args) @opts[:first] ||= 0 @opts[:last] ||= -1 end
Public Instance Methods
go(*args)
click to toggle source
Calls superclass method
Rbkb::Cli::Executable#go
# File lib/rbkb/cli/crc32.rb, line 27 def go(*args) super(*args) @opts[:indat] ||= @stdin.read() dat = opts[:indat].force_to_binary dat = dat[ @opts[:first] .. @opts[:last] ] dat ||= "" @stdout.puts( "%0.8x" % dat.force_to_binary.crc32 ) self.exit(0) end
make_parser()
click to toggle source
Calls superclass method
Rbkb::Cli::Executable#make_parser
# File lib/rbkb/cli/crc32.rb, line 14 def make_parser() arg = super() arg.banner += " [filename]" add_std_file_opt(:indat) add_range_opts(:first, :last) end
parse(*args)
click to toggle source
Calls superclass method
Rbkb::Cli::Executable#parse
# File lib/rbkb/cli/crc32.rb, line 21 def parse(*args) super(*args) parse_file_argument(:indat) parse_catchall() end