Class: Runestone::WebSearch::Token
- Inherits:
-
Object
- Object
- Runestone::WebSearch::Token
- Defined in:
- lib/runestone/web_search/token.rb
Instance Attribute Summary collapse
-
#alts ⇒ Object
Returns the value of attribute alts.
-
#negative ⇒ Object
Returns the value of attribute negative.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, prefix: false, negative: false, alts: nil) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(value, prefix: false, negative: false, alts: nil) ⇒ Token
Returns a new instance of Token.
3 4 5 6 7 8 |
# File 'lib/runestone/web_search/token.rb', line 3 def initialize(value, prefix: false, negative: false, alts: nil) @value = value @prefix = prefix @negative = negative @alts = alts || [] end |
Instance Attribute Details
#alts ⇒ Object
Returns the value of attribute alts.
2 3 4 |
# File 'lib/runestone/web_search/token.rb', line 2 def alts @alts end |
#negative ⇒ Object
Returns the value of attribute negative.
2 3 4 |
# File 'lib/runestone/web_search/token.rb', line 2 def negative @negative end |
#prefix ⇒ Object
Returns the value of attribute prefix.
2 3 4 |
# File 'lib/runestone/web_search/token.rb', line 2 def prefix @prefix end |
#value ⇒ Object
Returns the value of attribute value.
2 3 4 |
# File 'lib/runestone/web_search/token.rb', line 2 def value @value end |
Instance Method Details
#to_s ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/runestone/web_search/token.rb', line 10 def to_s if negative "!#{value}" elsif prefix if alts.empty? "#{value}:*" else "(#{value}:* | #{alts.join(' | ')})" end else if alts.empty? value else "(#{value} | #{alts.join(' | ')})" end end end |