Class: Justy::Finder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFinder

Returns a new instance of Finder.



12
13
14
15
# File 'lib/justy/finder.rb', line 12

def initialize
  super
  @parser = Parser.new
end

Instance Attribute Details

#find_commandObject (readonly)

Returns the value of attribute find_command.



10
11
12
# File 'lib/justy/finder.rb', line 10

def find_command
  @find_command
end

#parserObject (readonly)

Returns the value of attribute parser.



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

def parser
  @parser
end

Instance Method Details

#folder_for_options(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/justy/finder.rb', line 28

def folder_for_options(options)
  if (options[:relative])
    folder_path = Dir.pwd
    if (options[:folder])
      folder_path = folder_path + "/" + options[:folder]
    end
  else
    folder_path = options[:folder]
  end
  return folder_path
end

#run(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/justy/finder.rb', line 17

def run(args)
  options = @parser.parse(args)
  if (!options[:type].nil?)
    @find_command = FindCommandFactory.create_command(options[:type].to_sym)
    folder = folder_for_options(options)
    @find_command.run(folder)
  else
    puts @parser.options_parser
  end
end