Class: SchemaToScaffold::Path
- Inherits:
-
Object
- Object
- SchemaToScaffold::Path
- Defined in:
- lib/schema_to_scaffold/path.rb
Overview
Deal with the path argument
Instance Method Summary collapse
-
#choose ⇒ Object
Return the chosen path.
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
Constructor Details
#initialize(path) ⇒ Path
Returns a new instance of Path.
8 9 10 |
# File 'lib/schema_to_scaffold/path.rb', line 8 def initialize(path) @path = path || Dir.pwd end |
Instance Method Details
#choose ⇒ Object
Return the chosen path
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/schema_to_scaffold/path.rb', line 14 def choose validate_path search_paths_list = search_paths if search_paths_list.empty? puts "\nThere is no /schema[^\/]*.rb$/ in the directory #{@path}" exit end search_paths_list.each_with_index {|path,indx| puts "#{indx}. #{path}" } begin print "\nSelect a path to the target schema: " while search_paths_list[(id = STDIN.gets.to_i)].nil?; end rescue Interrupt => e exit 1 end search_paths_list[id] end |