Class: Stat

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, name) ⇒ Stat

Returns a new instance of Stat.



6
7
8
9
10
# File 'lib/stat.rb', line 6

def initialize(instance, name)
    @instance=instance
    @name=name
    @value=0
end

Instance Attribute Details

#collected_atObject (readonly)

Returns the value of attribute collected_at.



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

def collected_at
  @collected_at
end

#instanceObject (readonly)

Returns the value of attribute instance.



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

def instance
  @instance
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#to_hashObject



17
18
19
20
21
# File 'lib/stat.rb', line 17

def to_hash
    hash = {}
    instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
    hash
end