Class: Grafana::TimeWindow

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
lib/grafana/time_window.rb

Overview

Allows for easy formatting and manipulations of timestamps coming from a Grafana url

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(from, to) ⇒ TimeWindow

Returns a new instance of TimeWindow.


9
10
11
12
# File 'lib/grafana/time_window.rb', line 9

def initialize(from, to)
  @from = from
  @to = to
end

Instance Method Details

#formattedObject


14
15
16
17
18
19
# File 'lib/grafana/time_window.rb', line 14

def formatted
  {
    start: window[:from].formatted,
    end: window[:to].formatted
  }
end

#in_millisecondsObject


21
22
23
# File 'lib/grafana/time_window.rb', line 21

def in_milliseconds
  window.transform_values(&:to_ms)
end