Class: Ldpath::FunctionSelector
- Defined in:
- lib/ldpath/selectors.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#fname ⇒ Object
readonly
Returns the value of attribute fname.
Instance Method Summary collapse
- #evaluate(program, uris, context) ⇒ Object
-
#initialize(fname, arguments = []) ⇒ FunctionSelector
constructor
A new instance of FunctionSelector.
Methods inherited from Selector
Constructor Details
#initialize(fname, arguments = []) ⇒ FunctionSelector
Returns a new instance of FunctionSelector.
53 54 55 56 |
# File 'lib/ldpath/selectors.rb', line 53 def initialize(fname, arguments = []) @fname = fname @arguments = Array(arguments) end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
51 52 53 |
# File 'lib/ldpath/selectors.rb', line 51 def arguments @arguments end |
#fname ⇒ Object (readonly)
Returns the value of attribute fname.
51 52 53 |
# File 'lib/ldpath/selectors.rb', line 51 def fname @fname end |
Instance Method Details
#evaluate(program, uris, context) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ldpath/selectors.rb', line 58 def evaluate(program, uris, context) return to_enum(:evaluate, program, uris, context) unless block_given? enum_wrap(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 enum_flatten_one(program.func_call(fname, uri, context, *args)).each do |x| yield x unless x.nil? end end end |