Class: Sanity::Groq::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/sanity/groq/filter.rb

Constant Summary collapse

START_PAREN =
"("
END_PAREN =
")"
COMPARISON_OPERATORS =
{
  is: "==",
  not: "!=",
  gt: ">",
  gt_eq: ">=",
  lt: "<",
  lt_eq: "<=",
  match: "match"
}
LOGICAL_OPERATORS =
{
  and: "&&",
  or: "||"
}
RESERVED =
COMPARISON_OPERATORS.keys | LOGICAL_OPERATORS.keys

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Filter

Returns a new instance of Filter.



37
38
39
40
# File 'lib/sanity/groq/filter.rb', line 37

def initialize(**args)
  @args = args.except(*Sanity::Groqify::RESERVED - RESERVED)
  @filter_value = +""
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



35
36
37
# File 'lib/sanity/groq/filter.rb', line 35

def args
  @args
end

#filter_valueObject (readonly)

Returns the value of attribute filter_value.



35
36
37
# File 'lib/sanity/groq/filter.rb', line 35

def filter_value
  @filter_value
end

Class Method Details

.call(**args) ⇒ Object



10
11
12
# File 'lib/sanity/groq/filter.rb', line 10

def call(**args)
  new(**args).call
end

Instance Method Details

#callObject



42
43
44
45
# File 'lib/sanity/groq/filter.rb', line 42

def call
  iterate
  filter_value.strip
end