Class: Instrumental::Command

Inherits:
Struct
  • Object
show all
Defined in:
lib/instrumental/command_structs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, metric, value, time, count) ⇒ Command

Returns a new instance of Command.



5
6
7
# File 'lib/instrumental/command_structs.rb', line 5

def initialize(command, metric, value, time, count)
  super(command, metric, value, time.to_i, count.to_i)
end

Instance Attribute Details

#commandObject

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



4
5
6
# File 'lib/instrumental/command_structs.rb', line 4

def command
  @command
end

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



4
5
6
# File 'lib/instrumental/command_structs.rb', line 4

def count
  @count
end

#metricObject

Returns the value of attribute metric

Returns:

  • (Object)

    the current value of metric



4
5
6
# File 'lib/instrumental/command_structs.rb', line 4

def metric
  @metric
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of time



4
5
6
# File 'lib/instrumental/command_structs.rb', line 4

def time
  @time
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/instrumental/command_structs.rb', line 4

def value
  @value
end

Instance Method Details

#+(other_command) ⇒ Object



17
18
19
20
# File 'lib/instrumental/command_structs.rb', line 17

def +(other_command)
  return self if other_command.nil?
  Command.new(command, metric, value + other_command.value, time, count + other_command.count)
end

#metadataObject



13
14
15
# File 'lib/instrumental/command_structs.rb', line 13

def 
  "#{metric}:#{time}".freeze
end

#to_sObject



9
10
11
# File 'lib/instrumental/command_structs.rb', line 9

def to_s
  [command, metric, value, time, count].map(&:to_s).join(" ")
end