Class: Rake::Funnel::Support::Finder

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rake/funnel/support/internal/finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(search_pattern, task, message = nil) ⇒ Finder

Returns a new instance of Finder.



7
8
9
10
11
# File 'lib/rake/funnel/support/internal/finder.rb', line 7

def initialize(search_pattern, task, message = nil)
  @search_pattern = search_pattern
  @task = task
  @message = message
end

Instance Method Details

#allObject



34
35
36
37
38
39
40
# File 'lib/rake/funnel/support/internal/finder.rb', line 34

def all
  if candidates.empty?
    raise Rake::Funnel::AmbiguousFileError.new(@message, @task.name, @search_pattern, candidates)
  end

  candidates
end

#all_or_defaultObject



30
31
32
# File 'lib/rake/funnel/support/internal/finder.rb', line 30

def all_or_default
  candidates
end

#eachObject



13
14
15
16
# File 'lib/rake/funnel/support/internal/finder.rb', line 13

def each
  block_given? or return enum_for(__method__)
  all_or_default.each { |x| yield x }
end

#singleObject



22
23
24
25
26
27
28
# File 'lib/rake/funnel/support/internal/finder.rb', line 22

def single
  if first_sln.nil?
    raise Rake::Funnel::AmbiguousFileError.new(@message, @task.name, @search_pattern, candidates)
  end

  first_sln
end

#single_or_defaultObject



18
19
20
# File 'lib/rake/funnel/support/internal/finder.rb', line 18

def single_or_default
  first_sln
end