Class: Ldpath::RecursivePathSelector
- Defined in:
- lib/ldpath/selectors.rb
Instance Attribute Summary collapse
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#repeat ⇒ Object
readonly
Returns the value of attribute repeat.
Instance Method Summary collapse
- #evaluate(program, uris, context) ⇒ Object
-
#initialize(property, repeat) ⇒ RecursivePathSelector
constructor
A new instance of RecursivePathSelector.
Methods inherited from Selector
Constructor Details
#initialize(property, repeat) ⇒ RecursivePathSelector
Returns a new instance of RecursivePathSelector.
90 91 92 93 |
# File 'lib/ldpath/selectors.rb', line 90 def initialize(property, repeat) @property = property @repeat = repeat end |
Instance Attribute Details
#property ⇒ Object (readonly)
Returns the value of attribute property.
89 90 91 |
# File 'lib/ldpath/selectors.rb', line 89 def property @property end |
#repeat ⇒ Object (readonly)
Returns the value of attribute repeat.
89 90 91 |
# File 'lib/ldpath/selectors.rb', line 89 def repeat @repeat end |
Instance Method Details
#evaluate(program, uris, context) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ldpath/selectors.rb', line 95 def evaluate(program, uris, context) result = [] input = Array(uris) Range.new(0, repeat.min, true).each do input = property.evaluate program, input, context end repeat.each_with_index do |i, idx| break if input.empty? || idx > 25 # we're probably lost.. input = property.evaluate program, input, context result |= input end result.flatten.compact end |