Class: Grafana::RangeWithDefaults

Inherits:
Object
  • Object
show all
Defined in:
lib/grafana/time_window.rb

Overview

For incomplete time ranges, adds default parameters to achieve a complete range. If both full range is provided, range will be returned.

Constant Summary collapse

DEFAULT_RANGE =
8.hours

Instance Method Summary collapse

Constructor Details

#initialize(from: nil, to: nil) ⇒ RangeWithDefaults

Returns a new instance of RangeWithDefaults.

Parameters:


55
56
57
58
59
60
# File 'lib/grafana/time_window.rb', line 55

def initialize(from: nil, to: nil)
  @from = from
  @to = to

  apply_defaults!
end

Instance Method Details

#to_hashObject


62
63
64
# File 'lib/grafana/time_window.rb', line 62

def to_hash
  { from: @from, to: @to }.compact
end