Class: Psychic::Runner::SampleFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/psychic/runner/sample_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search_dir = Dir.pwd, hints = nil) ⇒ SampleFinder

Returns a new instance of SampleFinder.



6
7
8
9
# File 'lib/psychic/runner/sample_finder.rb', line 6

def initialize(search_dir = Dir.pwd, hints = nil)
  @search_dir = search_dir
  @hints = hints || {}
end

Instance Attribute Details

#hintsObject

Returns the value of attribute hints.



4
5
6
# File 'lib/psychic/runner/sample_finder.rb', line 4

def hints
  @hints
end

Instance Method Details

#find_sample(name) ⇒ Object



17
18
19
20
# File 'lib/psychic/runner/sample_finder.rb', line 17

def find_sample(name)
  file = find_in_hints(name) || Psychic::Util.find_file_by_alias(name, @search_dir)
  CodeSample.new(name, file, @search_dir)
end

#known_samplesObject



11
12
13
14
15
# File 'lib/psychic/runner/sample_finder.rb', line 11

def known_samples
  hints.map do | name, file |
    CodeSample.new(name, file, @search_dir)
  end
end