Class: Sobriquet::CommandCollection
- Inherits:
-
Object
- Object
- Sobriquet::CommandCollection
- Defined in:
- lib/sobriquet/command_collection.rb
Overview
Contain a collection of commands
Instance Method Summary collapse
- #add(data) ⇒ Object
- #compile ⇒ Object
- #get ⇒ Object
-
#initialize(persistance) ⇒ CommandCollection
constructor
A new instance of CommandCollection.
Constructor Details
#initialize(persistance) ⇒ CommandCollection
Returns a new instance of CommandCollection.
6 7 8 9 10 |
# File 'lib/sobriquet/command_collection.rb', line 6 def initialize(persistance) @persistance = persistance @commands = [] @title = %w(command alias description type) end |
Instance Method Details
#add(data) ⇒ Object
16 17 18 19 |
# File 'lib/sobriquet/command_collection.rb', line 16 def add(data) @commands.push(data) @persistance.save(@commands, @title) end |
#compile ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sobriquet/command_collection.rb', line 21 def compile Mustache.render( '{{#commands}} # description : {{description}} alias {{alias}}="{{value}}" {{/commands}} {{#variables}} # description : {{description}} export {{alias}}="{{value}}" {{/variables}}', commands: @persistance.get('command'), variables: @persistance.get('variable') ) end |
#get ⇒ Object
12 13 14 |
# File 'lib/sobriquet/command_collection.rb', line 12 def get @commands end |