Class: Nmg::Type::Process

Inherits:
Base
  • Object
show all
Defined in:
lib/nmg/type/process.rb

Overview

Define process with all it’s attributes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#operationsArray[Integer]

Returns the operations attribute.

Returns:

  • (Array[Integer])

    the operations attribute



8
# File 'lib/nmg/type/process.rb', line 8

attribute :operations, Array[Integer]

Class Method Details

.generate(count, options = {}, gen = Random.new) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/nmg/type/process.rb', line 14

def self.generate(count, options = {}, gen = Random.new)
  options = {operations: 3, min: 1, max: 20}.merge(options)

  operations = options[:operations]
  range = (options[:min]..options[:max])

  count.times.map do
    new(operations: operations.times.map { gen.rand(range) })
  end
end

Instance Method Details

#to_json(options = {}) ⇒ Object



10
11
12
# File 'lib/nmg/type/process.rb', line 10

def to_json(options = {})
  operations.to_json(options)
end