Class: FastRI::RiService::MatchFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/fastri/ri_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMatchFinder

Returns a new instance of MatchFinder.



80
81
82
# File 'lib/fastri/ri_service.rb', line 80

def initialize
  @matchers = {}
end

Class Method Details

.new {|ret| ... } ⇒ Object

Yields:

  • (ret)


74
75
76
77
78
# File 'lib/fastri/ri_service.rb', line 74

def self.new
  ret = super
  yield ret if block_given?
  ret
end

Instance Method Details

#add_matcher(name, &block) ⇒ Object



84
85
86
# File 'lib/fastri/ri_service.rb', line 84

def add_matcher(name, &block)
  @matchers[name] = block
end

#get_matches(methods) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/fastri/ri_service.rb', line 88

def get_matches(methods)
  catch(:MatchFinder_return) do
    methods.each do |name|
      matcher = @matchers[name]
      matcher.call(self) if matcher
    end
    []
  end
end

#yield(matches) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/fastri/ri_service.rb', line 98

def yield(matches)
  case matches
  when nil, []; nil
  when Array
    throw :MatchFinder_return, matches
  else
    throw :MatchFinder_return, [matches]
  end
end