Class: Sobriquet::CommandCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/sobriquet/command_collection.rb

Overview

Contain a collection of commands

Instance Method Summary collapse

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

#compileObject



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

#getObject



12
13
14
# File 'lib/sobriquet/command_collection.rb', line 12

def get
  @commands
end