Class: Transmogrifier::Selector

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

Constant Summary collapse

FILTER_REGEX =
/\[(.*)\]/
OPERATORS =
["!=", "="]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys) ⇒ Selector

Returns a new instance of Selector.



19
20
21
# File 'lib/transmogrifier/selector.rb', line 19

def initialize(keys)
  @keys = keys
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



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

def keys
  @keys
end

Class Method Details

.from_string(string) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/transmogrifier/selector.rb', line 8

def self.from_string(string)
  new(
    string.split(".").map do |str|
      match = str.scan(FILTER_REGEX).flatten.first
      match ? match.split(",").map {|s| to_array(s)}  : str
    end
  )
end