Class: SpectatorSport::SearchQuery::SyntaxTree::Label

Inherits:
Object
  • Object
show all
Defined in:
app/models/spectator_sport/search_query/syntax_tree.rb

Overview

Leaf node: a single label:... term. A "*" anywhere inside the value (other than standing alone as label:key:*, which already means "any value") acts as a wildcard matching zero or more characters, e.g. label:user_id:2* matches any value starting with "2".

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, value:, wildcard: false) ⇒ Label

Returns a new instance of Label.



18
19
20
21
22
# File 'app/models/spectator_sport/search_query/syntax_tree.rb', line 18

def initialize(key:, value:, wildcard: false)
  @key = key
  @value = value
  @wildcard = wildcard
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



15
16
17
# File 'app/models/spectator_sport/search_query/syntax_tree.rb', line 15

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



15
16
17
# File 'app/models/spectator_sport/search_query/syntax_tree.rb', line 15

def value
  @value
end

#wildcardObject (readonly) Also known as: wildcard?

Returns the value of attribute wildcard.



15
16
17
# File 'app/models/spectator_sport/search_query/syntax_tree.rb', line 15

def wildcard
  @wildcard
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
# File 'app/models/spectator_sport/search_query/syntax_tree.rb', line 28

def ==(other)
  other.is_a?(self.class) && other.key == key && other.value == value && other.wildcard == wildcard
end

#to_scopeObject



24
25
26
# File 'app/models/spectator_sport/search_query/syntax_tree.rb', line 24

def to_scope
  SpectatorSport::Recording.where(id: labels_scope.select(:id))
end