Class: Empp::Utils::Utils

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

Class Method Summary collapse

Class Method Details

.getTimestampInt(now) ⇒ Object

MMDDHHMMSS



12
13
14
15
# File 'lib/empp/utils/utils.rb', line 12

def self.getTimestampInt(now)
  u8 = BinData::Uint8.new
  intVal = now.month * 10**8 + now.day * 10**6 + now.hour * 10**4 + now.min * 10**2 +             now.sec
end

.getTimestampStr(now) ⇒ Object



17
18
19
# File 'lib/empp/utils/utils.rb', line 17

def self.getTimestampStr(now)
  now.month.to_s.rjust(2, "0") + now.day.to_s.rjust(2, "0") + now.hour.to_s.rjust(2, "0") + now.min.to_s.rjust(2, "0") + now.sec.to_s.rjust(2, "0")
end

.getUintBe(intValue) ⇒ Object



27
28
29
30
31
# File 'lib/empp/utils/utils.rb', line 27

def self.getUintBe(intValue)
  ibe = BinData::Uint32be.new
  ibe.assign( intValue )
  ibe.to_binary_s
end

.getUintLe(intValue) ⇒ Object



21
22
23
24
25
# File 'lib/empp/utils/utils.rb', line 21

def self.getUintLe(intValue)
  ibe = BinData::Uint32le.new
  ibe.assign( intValue )
  ibe.to_binary_s
end

.getVersionObject



33
34
35
36
37
38
# File 'lib/empp/utils/utils.rb', line 33

def self.getVersion
  version = 0b00010000
  u8 = BinData::Uint8be.new
  u8.assign(version)
  u8.to_binary_s
end