Class: Simplprinter::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/simplprinter/payload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePayload

Returns a new instance of Payload.



6
7
8
9
10
11
12
13
14
# File 'lib/simplprinter/payload.rb', line 6

def initialize
  self.vars_arr  = []
  self.iters_arr = []
  self.iterations_raw = []
  
  require 'ostruct'
  self.payload_raw = OpenStruct.new
  self.var = OpenStruct.new
end

Instance Attribute Details

#iterations_rawObject

Returns the value of attribute iterations_raw.



4
5
6
# File 'lib/simplprinter/payload.rb', line 4

def iterations_raw
  @iterations_raw
end

#iters_arrObject

Returns the value of attribute iters_arr.



4
5
6
# File 'lib/simplprinter/payload.rb', line 4

def iters_arr
  @iters_arr
end

#payload_rawObject

Returns the value of attribute payload_raw.



4
5
6
# File 'lib/simplprinter/payload.rb', line 4

def payload_raw
  @payload_raw
end

#varObject

Returns the value of attribute var.



4
5
6
# File 'lib/simplprinter/payload.rb', line 4

def var
  @var
end

#vars_arrObject

Returns the value of attribute vars_arr.



4
5
6
# File 'lib/simplprinter/payload.rb', line 4

def vars_arr
  @vars_arr
end

Instance Method Details

#add_variable(name, value) ⇒ Object



16
17
18
# File 'lib/simplprinter/payload.rb', line 16

def add_variable(name, value)
  self.var["#{name}"]= value
end

#bundle_itObject

def add_iteration(iteration)

  self.iters_arr << iteration.marshal_dump
end


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/simplprinter/payload.rb', line 30

def bundle_it
  self.vars_arr << var.marshal_dump
  
  self.iterations_raw.each do |i|
    self.iters_arr << i.bundle_it.marshal_dump
  end
  
  self.payload_raw.iterations = self.iters_arr
  self.payload_raw.variables  = self.vars_arr

  payload = self.payload_raw.marshal_dump.to_json
  payload
end

#new_iteration(name) ⇒ Object



20
21
22
23
24
# File 'lib/simplprinter/payload.rb', line 20

def new_iteration(name)
  iteration = Iteration.new(name)
  self.iterations_raw << iteration
  iteration
end