Class: CheckInput

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

Overview

test arguments for trailing ‘/’, emptiness and validity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCheckInput

Returns a new instance of CheckInput.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sort.rb', line 10

def initialize
  if ARGV.empty?
    @dir = Dir.pwd
  else
    @dir=ARGV[0]
  end
  @dir += '/' unless @dir[-1] == '/'
  unless Dir.exist?(@dir)
    return puts "#{@dir} is not a valid directory"
    abort
  end
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



9
10
11
# File 'lib/sort.rb', line 9

def dir
  @dir
end