class Hoss::Config::Bytes

@api private

Constants

MULTIPLIERS
REGEX

Public Class Methods

new(default_unit: 'kb') click to toggle source
# File lib/hoss/config/bytes.rb, line 31
def initialize(default_unit: 'kb')
  @default_unit = default_unit
end

Public Instance Methods

call(value) click to toggle source
# File lib/hoss/config/bytes.rb, line 35
def call(value)
  _, amount, unit = REGEX.match(String(value)).to_a
  unit ||= @default_unit
  MULTIPLIERS.fetch(unit.downcase, 1) * amount.to_i
end