Class: Axe::API::Selector

Inherits:
Object
  • Object
show all
Defined in:
lib/axe/api/selector.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ Selector

Returns a new instance of Selector.



16
17
18
19
20
21
22
23
# File 'lib/axe/api/selector.rb', line 16

def initialize(s)
  @selector = case s
              when Array then s
              when String, Symbol then [String(s)]
              when Hash then Selector.new(s[:selector]).to_a.unshift s[:iframe]
              else Selector.new(s.selector).to_a.unshift s.iframe
              end
end

Class Method Details

.normalize(s) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/axe/api/selector.rb', line 4

def self.normalize(s)
  if s.is_a? Hash
    if s.key? :iframe and s.key? :selector
      Array(Selector.new s)
    else
      s
    end
  else
    Array(Selector.new s)
  end
end

Instance Method Details

#to_aObject



25
26
27
# File 'lib/axe/api/selector.rb', line 25

def to_a
  @selector
end