Class: SqlChatbot::Grammar::Registry
- Inherits:
-
Object
- Object
- SqlChatbot::Grammar::Registry
- Defined in:
- lib/sql_chatbot/grammar/registry.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
-
#framework ⇒ Object
readonly
Returns the value of attribute framework.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #find_entity(name) ⇒ Object
-
#initialize(framework:, entities: {}, aliases: {}) ⇒ Registry
constructor
A new instance of Registry.
- #resolve_alias(term) ⇒ Object
Constructor Details
#initialize(framework:, entities: {}, aliases: {}) ⇒ Registry
Returns a new instance of Registry.
47 48 49 50 51 52 53 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 47 def initialize(framework:, entities: {}, aliases: {}) @framework = framework @entities = entities @aliases = aliases @version = 1 @generated_at = Time.now.utc.iso8601 end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
45 46 47 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 45 def aliases @aliases end |
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
45 46 47 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 45 def entities @entities end |
#framework ⇒ Object (readonly)
Returns the value of attribute framework.
45 46 47 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 45 def framework @framework end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
45 46 47 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 45 def generated_at @generated_at end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
45 46 47 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 45 def version @version end |
Instance Method Details
#find_entity(name) ⇒ Object
55 56 57 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 55 def find_entity(name) @entities[name.to_s] end |
#resolve_alias(term) ⇒ Object
59 60 61 62 63 |
# File 'lib/sql_chatbot/grammar/registry.rb', line 59 def resolve_alias(term) return @aliases[term.to_s] if @aliases.key?(term.to_s) return term.to_s if @entities.key?(term.to_s) nil end |