Class: AstDB::Entry
- Inherits:
-
Object
- Object
- AstDB::Entry
- Defined in:
- lib/astdb/models/entry.rb
Instance Attribute Summary collapse
-
#family ⇒ Object
Returns the value of attribute family.
-
#key ⇒ Object
Returns the value of attribute key.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(key, value) ⇒ Entry
constructor
A new instance of Entry.
- #put_command ⇒ Object
Constructor Details
#initialize(key, value) ⇒ Entry
Returns a new instance of Entry.
6 7 8 9 10 11 12 13 |
# File 'lib/astdb/models/entry.rb', line 6 def initialize(key, value) m = key.match /^(?<family>.+)\/(?<key>[^\/]+)$/ raise ArgumentError, 'key must at least have a single "/" delimiting the asterisk family and key values' if m.nil? @family = m[:family] @key = m[:key] @value = value end |
Instance Attribute Details
#family ⇒ Object
Returns the value of attribute family.
4 5 6 |
# File 'lib/astdb/models/entry.rb', line 4 def family @family end |
#key ⇒ Object
Returns the value of attribute key.
4 5 6 |
# File 'lib/astdb/models/entry.rb', line 4 def key @key end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/astdb/models/entry.rb', line 4 def value @value end |
Instance Method Details
#put_command ⇒ Object
15 16 17 |
# File 'lib/astdb/models/entry.rb', line 15 def put_command "database put #{family} #{key} #{value}" end |