Class: KeywordSearch::Definition::Keyword
- Inherits:
-
Object
- Object
- KeywordSearch::Definition::Keyword
- Defined in:
- lib/keyword_search/definition.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #handle(value, sign) ⇒ Object
-
#initialize(name, description = nil, &handler) ⇒ Keyword
constructor
A new instance of Keyword.
Constructor Details
#initialize(name, description = nil, &handler) ⇒ Keyword
Returns a new instance of Keyword.
8 9 10 11 |
# File 'lib/keyword_search/definition.rb', line 8 def initialize(name, description=nil, &handler) @name, @description = name, description @handler = handler end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/keyword_search/definition.rb', line 7 def description @description end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
7 8 9 |
# File 'lib/keyword_search/definition.rb', line 7 def handler @handler end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/keyword_search/definition.rb', line 7 def name @name end |
Instance Method Details
#handle(value, sign) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/keyword_search/definition.rb', line 13 def handle(value, sign) # If the handler is only expecting one argument, # only give them the positive matches if handler.arity == 1 handler.call(value) if sign else handler.call(value, sign) end end |