Class: Deck::Container::Variable

Inherits:
Object
  • Object
show all
Includes:
Submodule
Defined in:
lib/deck/container/variable.rb

Instance Method Summary collapse

Methods included from Submodule

#attributes, #build_command, #get, included, #map, #set, #value

Constructor Details

#initializeVariable

Returns a new instance of Variable.



7
8
9
# File 'lib/deck/container/variable.rb', line 7

def initialize
  @variables = {}
end

Instance Method Details

#define(name, value) ⇒ Object



11
12
13
# File 'lib/deck/container/variable.rb', line 11

def define(name, value)
  @variables[name.to_sym] = value
end

#metaObject



27
28
29
# File 'lib/deck/container/variable.rb', line 27

def meta
  @variables.dup.freeze
end

#prepareObject



15
16
17
# File 'lib/deck/container/variable.rb', line 15

def prepare
  Hash[*@variables.map { |k,v| [k, "::#{k}::"]}.flatten].dup.freeze
end

#process(command) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/deck/container/variable.rb', line 19

def process(command)
  @variables.each do |k,v|
    command.gsub! "::#{k}::", v.to_s
  end

  command
end