Class: Infoboxer::Navigation::Lookup::Selector
- Inherits:
-
Object
- Object
- Infoboxer::Navigation::Lookup::Selector
- 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
-
#arg ⇒ Object
readonly
Returns the value of attribute arg.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(*arg, &block) ⇒ Selector
constructor
A new instance of Selector.
- #inspect ⇒ Object
- #matches?(node) ⇒ Boolean
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
#arg ⇒ Object (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 |
#inspect ⇒ Object
24 25 26 |
# File 'lib/infoboxer/navigation/selector.rb', line 24 def inspect "#<Selector(#{@arg.map(&:to_s).join(', ')})>" end |
#matches?(node) ⇒ Boolean
28 29 30 |
# File 'lib/infoboxer/navigation/selector.rb', line 28 def matches?(node) @arg.all?{|a| arg_matches?(a, node)} end |