Class: CheckInput
- Inherits:
-
Object
- Object
- CheckInput
- Defined in:
- lib/sort.rb
Overview
test arguments for trailing ‘/’, emptiness and validity
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize ⇒ CheckInput
constructor
A new instance of CheckInput.
Constructor Details
#initialize ⇒ CheckInput
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
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
9 10 11 |
# File 'lib/sort.rb', line 9 def dir @dir end |