Class: Reverse
- Inherits:
-
Object
- Object
- Reverse
- Defined in:
- lib/reverse.rb,
lib/reverse/version.rb
Constant Summary collapse
- ADDR_REG_EXP =
/\b((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\b/
- VERSION =
"0.0.7"
Instance Method Summary collapse
- #exec(argv) ⇒ Object
-
#initialize ⇒ Reverse
constructor
A new instance of Reverse.
Constructor Details
#initialize ⇒ Reverse
Returns a new instance of Reverse.
10 11 12 13 14 15 |
# File 'lib/reverse.rb', line 10 def initialize @resolv = Resolv::DNS.new(nameserver: ["8.8.8.8", "8.8.4.4"], ndots: 1) @list = {} @options = {color: true} Signal.trap(:INT){ exit(0) } end |
Instance Method Details
#exec(argv) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/reverse.rb', line 17 def exec(argv) opt = OptionParser.new opt.on('-V', '--verion', 'Show version number and quit') {|v| @options[:verion] = v } opt.on('-v', '--verbose', 'Verbose Mode (IP Address with reverse DNS)') {|v| @options[:verbose] = v } opt.on('--no-color', 'No Color Mode') {|v| @options[:color] = v } opt.parse!(argv) if @options[:verion] name = File.basename($PROGRAM_NAME) puts "#{name} #{VERSION}" exit end while line = gets output = if line =~ ADDR_REG_EXP replace_addr(line) else line end print output end end |