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

Inherits:
Object
  • Object
show all
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.



8
9
10
11
12
13
# File 'lib/infoboxer/navigation/selector.rb', line 8

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.



15
16
17
# File 'lib/infoboxer/navigation/selector.rb', line 15

def arg
  @arg
end

Instance Method Details

#==(other) ⇒ Object



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

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

#===(other) ⇒ Object



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

def ===(other)
  @arg.all? { |a| arg_matches?(a, other) }
end

#inspectObject



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

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