Class: Nyanko::Invoker::FunctionFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/nyanko/invoker/function_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, options) ⇒ FunctionFinder

Returns a new instance of FunctionFinder.



12
13
14
15
# File 'lib/nyanko/invoker/function_finder.rb', line 12

def initialize(context, options)
  @context = context
  @options = options
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/nyanko/invoker/function_finder.rb', line 8

def context
  @context
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/nyanko/invoker/function_finder.rb', line 8

def options
  @options
end

Class Method Details

.find(context, options) ⇒ Object



4
5
6
# File 'lib/nyanko/invoker/function_finder.rb', line 4

def self.find(context, options)
  new(context, options).find
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/nyanko/invoker/function_finder.rb', line 33

def active?
  unit.try(:active?, context, active_if_options)
end

#findObject



17
18
19
# File 'lib/nyanko/invoker/function_finder.rb', line 17

def find
  active? && find_function
end

#find_functionObject



29
30
31
# File 'lib/nyanko/invoker/function_finder.rb', line 29

def find_function
  unit.find_function(scope, label)
end

#scopeObject



21
22
23
# File 'lib/nyanko/invoker/function_finder.rb', line 21

def scope
  as || context.class
end

#unitObject



25
26
27
# File 'lib/nyanko/invoker/function_finder.rb', line 25

def unit
  Loader.load(unit_name)
end