Class: Senko::Vocabulary
- Inherits:
-
Object
- Object
- Senko::Vocabulary
- Defined in:
- lib/senko/vocabulary.rb
Instance Attribute Summary collapse
-
#custom_keywords ⇒ Object
readonly
Returns the value of attribute custom_keywords.
Instance Method Summary collapse
- #custom?(keyword) ⇒ Boolean
-
#initialize(custom_keywords = {}) ⇒ Vocabulary
constructor
A new instance of Vocabulary.
- #register(keyword, validator) ⇒ Object
- #validator_for(keyword) ⇒ Object
Constructor Details
#initialize(custom_keywords = {}) ⇒ Vocabulary
Returns a new instance of Vocabulary.
7 8 9 |
# File 'lib/senko/vocabulary.rb', line 7 def initialize(custom_keywords = {}) @custom_keywords = custom_keywords || {} end |
Instance Attribute Details
#custom_keywords ⇒ Object (readonly)
Returns the value of attribute custom_keywords.
5 6 7 |
# File 'lib/senko/vocabulary.rb', line 5 def custom_keywords @custom_keywords end |
Instance Method Details
#custom?(keyword) ⇒ Boolean
11 12 13 |
# File 'lib/senko/vocabulary.rb', line 11 def custom?(keyword) @custom_keywords.key?(keyword) end |
#register(keyword, validator) ⇒ Object
19 20 21 22 23 |
# File 'lib/senko/vocabulary.rb', line 19 def register(keyword, validator) raise ArgumentError, 'keyword validator must respond to call' unless validator.respond_to?(:call) @custom_keywords[keyword.to_s] = validator end |
#validator_for(keyword) ⇒ Object
15 16 17 |
# File 'lib/senko/vocabulary.rb', line 15 def validator_for(keyword) @custom_keywords[keyword] end |