Skip to content

Instantly share code, notes, and snippets.

@dimanon
Created April 8, 2012 12:05
Show Gist options
  • Save dimanon/2336872 to your computer and use it in GitHub Desktop.
Save dimanon/2336872 to your computer and use it in GitHub Desktop.
class Check
def initialize(arg)
@args = arg
end
def args_empty?
@args.empty?
end
def dirname?
if @args.first.split('/').last =~ /^[a-z][a-z\-]*$/
true
else
puts "Only lowercase-letters and '-' allowed in dirname!"
exit 1
end
end
def exists?
if File.directory?(@args.first)
puts "#{@args.first} exists!"
exit 1
else
true
end
end
def ok?
!args_empty? and dirname? and exists?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment