class Arboretum::Scandent::ListenerPath
Attributes
steps[RW]
Public Class Methods
new(steps=[])
click to toggle source
# File lib/arboretum/scandent.rb, line 67 def initialize(steps=[]) # Make sure that the listener stems from the root element if !steps.first.nil? and steps.first.element_ref != :ELEMENT_ROOT if steps.first.element_ref.nil? implied_step = [ [:T_TILDE, '~', :STATE_ROOT_PATH], [:T_SLASH2, '//', :STATE_ROOT_PATH] ] steps.unshift(Parser.parse_step_tokens(implied_step, :PATH_LISTENER)) elsif steps.first.element_ref == :ELEMENT_SELF steps.first.element_ref = :ELEMENT_ROOT end end # Make sure there are no misplaced :ELEMENT_SELF references steps.each {|step| raise InvalidExpressionException.new if step.element_ref == :ELEMENT_SELF and !step.eql?(steps.first)} @steps = steps end
Public Instance Methods
steps_valid_on?(steps, candidate)
click to toggle source
# File lib/arboretum/scandent.rb, line 90 def steps_valid_on?(steps, candidate) return true if steps.empty? steps.last.match(candidate) do |element| return true if steps_valid_on?(steps[0..-2], element) end return false end
to_s()
click to toggle source
# File lib/arboretum/scandent.rb, line 98 def to_s path_string = '' @steps.each{|step| path_string << step.to_s} path_string end
valid_on?(candidate)
click to toggle source
# File lib/arboretum/scandent.rb, line 86 def valid_on?(candidate) steps_valid_on?(@steps, candidate) end