Class: SimpleMetrics::DataPoint::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_metrics/data_point/base.rb

Direct Known Subclasses

Counter, Event, Gauge, Timing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Base

Returns a new instance of Base



9
10
11
12
13
14
15
16
17
# File 'lib/simple_metrics/data_point/base.rb', line 9

def initialize(attributes)
  @id          = attributes[:id]
  @name        = attributes[:name]
  @value       = attributes[:value]
  @ts          = attributes[:ts]
  @sample_rate = attributes[:sample_rate]
  @sum         = attributes[:sum]
  @total       = attributes[:total]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id



7
8
9
# File 'lib/simple_metrics/data_point/base.rb', line 7

def id
  @id
end

#nameObject

Returns the value of attribute name



6
7
8
# File 'lib/simple_metrics/data_point/base.rb', line 6

def name
  @name
end

#sumObject

Returns the value of attribute sum



6
7
8
# File 'lib/simple_metrics/data_point/base.rb', line 6

def sum
  @sum
end

#totalObject

Returns the value of attribute total



6
7
8
# File 'lib/simple_metrics/data_point/base.rb', line 6

def total
  @total
end

#tsObject

Returns the value of attribute ts



6
7
8
# File 'lib/simple_metrics/data_point/base.rb', line 6

def ts
  @ts
end

#typeObject

Returns the value of attribute type



6
7
8
# File 'lib/simple_metrics/data_point/base.rb', line 6

def type
  @type
end

#valueObject

Returns the value of attribute value



6
7
8
# File 'lib/simple_metrics/data_point/base.rb', line 6

def value
  @value
end

Instance Method Details

#attributesObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/simple_metrics/data_point/base.rb', line 43

def attributes
  { 
    :name  => @name,
    :value => @value,
    :ts    => @ts,
    :type  => @type,
    :total => @total,
    :sum   => @sum
  }
end

#counter?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/simple_metrics/data_point/base.rb', line 19

def counter?
  @type == 'c'
end

#event?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/simple_metrics/data_point/base.rb', line 31

def event?
  @type == 'ev'
end

#gauge?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/simple_metrics/data_point/base.rb', line 23

def gauge?
  @type == 'g'
end

#timestampObject



35
36
37
# File 'lib/simple_metrics/data_point/base.rb', line 35

def timestamp
  ts
end

#timing?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/simple_metrics/data_point/base.rb', line 27

def timing?
  @type == 'ms'
end

#to_sObject



54
55
56
# File 'lib/simple_metrics/data_point/base.rb', line 54

def to_s
  attributes.to_s
end