Module: Vector

Defined in:
lib/vector.rb,
lib/vector/cli.rb,
lib/vector/version.rb,
lib/vector/functions/predictive_scaling.rb,
lib/vector/functions/flexible_down_scaling.rb

Defined Under Namespace

Modules: Function, HLogger Classes: CLI

Constant Summary collapse

VERSION =
"0.0.6"

Class Method Summary collapse

Class Method Details

.time_string_to_seconds(string) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vector.rb', line 7

def self.time_string_to_seconds(string)
  if string =~ /^(\d+)([smhdw])?$/
    n = $1.to_i
    unit = $2 || 's'

    case unit
    when 's'
      n.seconds
    when 'm'
      n.minutes
    when 'h'
      n.hours
    when 'd'
      n.days
    when 'w'
      n.weeks
    end
  else
    nil
  end
end

.within_threshold(threshold, v1, v2) ⇒ Object



29
30
31
# File 'lib/vector.rb', line 29

def self.within_threshold(threshold, v1, v2)
  threshold * v1 < v2 && threshold * v2 < v1
end