Class: BaseFinder

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

Direct Known Subclasses

RailsFinder, ScriptFinder

Constant Summary collapse

DEFAULT_BIN_DIR =
'script'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, bin_dir = nil) ⇒ BaseFinder

Returns a new instance of BaseFinder.



20
21
22
23
# File 'lib/script_finder/base_finder.rb', line 20

def initialize(command, bin_dir = nil)
  @command = command
  self.bin_dir = bin_dir || DEFAULT_BIN_DIR
end

Instance Attribute Details

#bin_dirObject

Returns the value of attribute bin_dir.



10
11
12
# File 'lib/script_finder/base_finder.rb', line 10

def bin_dir
  @bin_dir
end

#commandObject (readonly)

Returns the value of attribute command.



11
12
13
# File 'lib/script_finder/base_finder.rb', line 11

def command
  @command
end

Class Method Details

.find_and_execute(command, bin_dir = nil) ⇒ Object



15
16
17
18
# File 'lib/script_finder/base_finder.rb', line 15

def self.find_and_execute(command, bin_dir = nil)
  command = command.split(' ') if command.is_a?(String)
  finder = new(command, bin_dir).execute_command
end

Instance Method Details

#execute_commandObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/script_finder/base_finder.rb', line 25

def execute_command
  raise NotImplementedError.new("You must implement execute_command for subclasses of BaseFinder!")
end