Class: Infoboxer::Navigation::Lookup::Selector

Inherits:
Object
  • Object
show all
Includes:
ProcMe
Defined in:
lib/infoboxer/navigation/selector.rb

Overview

Incapsulates storage of selectors, used in node lookup.

See Lookup::Node for detailed explanation of available selectors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arg, &block) ⇒ Selector

Returns a new instance of Selector.



11
12
13
14
15
16
# File 'lib/infoboxer/navigation/selector.rb', line 11

def initialize(*arg, &block)
  @arg = [arg, block].flatten.compact.map(&method(:sym_to_class))
  @arg.each do |a|
    a.reject!{|k, v| v.nil?} if a.is_a?(Hash)
  end
end

Instance Attribute Details

#argObject (readonly)

Returns the value of attribute arg.



18
19
20
# File 'lib/infoboxer/navigation/selector.rb', line 18

def arg
  @arg
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/infoboxer/navigation/selector.rb', line 20

def ==(other)
  self.class == other.class && arg == other.arg
end

#inspectObject



24
25
26
# File 'lib/infoboxer/navigation/selector.rb', line 24

def inspect
  "#<Selector(#{@arg.map(&:to_s).join(', ')})>"
end

#matches?(node) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/infoboxer/navigation/selector.rb', line 28

def matches?(node)
  @arg.all?{|a| arg_matches?(a, node)}
end