Class: Ldpath::FunctionSelector

Inherits:
Selector
  • Object
show all
Defined in:
lib/ldpath/selectors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Selector

#loading

Constructor Details

#initialize(fname, arguments = []) ⇒ FunctionSelector

Returns a new instance of FunctionSelector.



24
25
26
27
# File 'lib/ldpath/selectors.rb', line 24

def initialize(fname, arguments = [])
  @fname = fname
  @arguments = Array(arguments)
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



22
23
24
# File 'lib/ldpath/selectors.rb', line 22

def arguments
  @arguments
end

#fnameObject (readonly)

Returns the value of attribute fname.



22
23
24
# File 'lib/ldpath/selectors.rb', line 22

def fname
  @fname
end

Instance Method Details

#evaluate(program, uris, context) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ldpath/selectors.rb', line 29

def evaluate(program, uris, context)
  Array(uris).map do |uri|
    loading program, uri, context
    args = arguments.map do |i|
      case i
      when Selector
        i.evaluate(program, uri, context)
      else
        i
      end
    end
    program.func_call fname, uri, context, *args
  end.flatten.compact
end