Module: OctaSpace::PayloadHelpers

Defined in:
lib/octaspace/payload_helpers.rb

Class Method Summary collapse

Class Method Details

.normalize_marketplace_bandwidth(value) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/octaspace/payload_helpers.rb', line 22

def normalize_marketplace_bandwidth(value)
  numeric =
    case value
    when nil
      return nil
    when Numeric
      value.to_f
    when String
      Float(value)
    else
      return value
    end

  return numeric unless numeric > 100_000

  numeric / 125_000.0
rescue ArgumentError, TypeError
  value
end

.parse_port_list(value) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/octaspace/payload_helpers.rb', line 9

def parse_port_list(value)
  case value
  when nil
    []
  when Array
    value
  when String
    parse_stringified_port_list(value)
  else
    Array(value)
  end
end