Class: Sysdig::Model

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

Direct Known Subclasses

Alert, AlertNotification

Class Method Summary collapse

Class Method Details

.epoch_time(v, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/sysdig/model.rb', line 2

def self.epoch_time(v, options={})
  divisor = options[:divisor] || 1_000

  case v
  when Time then v
  when Numeric then Time.at(v / divisor)
  else nil
  end
end

.microsecond_datetime(v) ⇒ Object



12
13
14
15
16
# File 'lib/sysdig/model.rb', line 12

def self.microsecond_datetime(v, *)
  i = v.to_i

  i > 1_000_000 ? i / 1_000_000 : i
end

.upcase(v) ⇒ Object



18
19
20
# File 'lib/sysdig/model.rb', line 18

def self.upcase(v, *)
  v.nil? ? v : v.to_s.upcase
end