Class: PCPEasy::PMAPI::PmUnits

Inherits:
Object
  • Object
show all
Defined in:
lib/pcp_easy/pmapi/pm_units.rb

Instance Method Summary collapse

Constructor Details

#initialize(pm_units) ⇒ PmUnits

Decodes a 32bit integer into the correct fields of pmUnits. This implementation assumes little-endian encoding



8
9
10
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 8

def initialize(pm_units)
  @pm_units = pm_units
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 40

def ==(other)
  self.class == other.class && \
  dim_space == other.dim_space && \
  dim_time == other.dim_time && \
  dim_count == other.dim_count && \
  scale_space == other.scale_space && \
  scale_time == other.scale_time && \
  scale_count == other.scale_count
end

#dim_countObject



20
21
22
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 20

def dim_count
  signed_4_bit(@pm_units >> 20)
end

#dim_spaceObject



12
13
14
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 12

def dim_space
  signed_4_bit(@pm_units >> 28)
end

#dim_timeObject



16
17
18
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 16

def dim_time
  signed_4_bit(@pm_units >> 24)
end

#inspectObject



36
37
38
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 36

def inspect
  "<#{self.class.to_s}:#{object_id} @pm_units=#{@pm_units} {#{dim_space},#{dim_time},#{dim_count},#{scale_space},#{scale_time},#{scale_count}}>"
end

#scale_countObject



32
33
34
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 32

def scale_count
  signed_4_bit(@pm_units >> 8)
end

#scale_spaceObject



24
25
26
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 24

def scale_space
  unsigned_4_bit(@pm_units >> 16)
end

#scale_timeObject



28
29
30
# File 'lib/pcp_easy/pmapi/pm_units.rb', line 28

def scale_time
  unsigned_4_bit(@pm_units >> 12)
end