Class: Ldpath::RecursivePathSelector

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(property, repeat) ⇒ RecursivePathSelector

Returns a new instance of RecursivePathSelector.



75
76
77
78
# File 'lib/ldpath/selectors.rb', line 75

def initialize property, repeat
  @property = property
  @repeat = repeat
end

Instance Attribute Details

#property ⇒ Object (readonly)

Returns the value of attribute property.



74
75
76
# File 'lib/ldpath/selectors.rb', line 74

def property
  @property
end

#repeat ⇒ Object (readonly)

Returns the value of attribute repeat.



74
75
76
# File 'lib/ldpath/selectors.rb', line 74

def repeat
  @repeat
end

Instance Method Details

#evaluate(program, uris, context) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ldpath/selectors.rb', line 80

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? or idx > 25 # we're probably lost..
    input = property.evaluate program, input, context
    result |= input
  end
  result.flatten.compact
end