Class: Bri::Search::Method

Inherits:
Base
  • Object
show all
Defined in:
lib/bri/search/method.rb

Direct Known Subclasses

ClassMethod, InstanceMethod

Instance Attribute Summary collapse

Attributes inherited from Base

#matches, #term

Instance Method Summary collapse

Constructor Details

#initialize(term) ⇒ Method

Returns a new instance of Method.



6
7
8
9
10
11
12
13
14
15
# File 'lib/bri/search/method.rb', line 6

def initialize( term )
  super
  @class_term, @method_term = term.split( /[\.#]/, 2 )

  if @class_term !~ /^[A-Z]/ && !@method_term
    @method_term, @class_term = @class_term, @method_term
  end

  @class_term = nil if @class_term&.empty?
end

Instance Attribute Details

#class_termObject (readonly)

Returns the value of attribute class_term.



4
5
6
# File 'lib/bri/search/method.rb', line 4

def class_term
  @class_term
end

#method_termObject (readonly)

Returns the value of attribute method_term.



4
5
6
# File 'lib/bri/search/method.rb', line 4

def method_term
  @method_term
end

Instance Method Details

#search(type = :fully_qualified) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/bri/search/method.rb', line 17

def search( type = :fully_qualified )
  case type
    when :fully_qualified     then fully_qualified_search
    when :partially_qualified then partially_qualified_search
    when :unqualified         then unqualified_search
    else :error # TODO: Error handling
  end
end