Class: SpectatorSport::SearchQuery::SyntaxTree::Label
- Inherits:
-
Object
- Object
- SpectatorSport::SearchQuery::SyntaxTree::Label
- 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
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#wildcard ⇒ Object
(also: #wildcard?)
readonly
Returns the value of attribute wildcard.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(key:, value:, wildcard: false) ⇒ Label
constructor
A new instance of Label.
- #to_scope ⇒ Object
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
#key ⇒ Object (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 |
#value ⇒ Object (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 |
#wildcard ⇒ Object (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_scope ⇒ Object
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 |