Module: Noise::Modifier

Defined in:
lib/noise/pattern.rb

Defined Under Namespace

Classes: Fallback, Psk

Constant Summary collapse

PSK_REGEX =
/\Apsk(\d+)\z/

Class Method Summary collapse

Class Method Details

.parse(s) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/noise/pattern.rb', line 93

def self.parse(s)
  matched = PSK_REGEX.match(s)
  return Modifier::Psk.new(matched[1].to_i) if matched
  return Modifier::Fallback.new if s == 'fallback'

  raise Noise::Exceptions::UnsupportedModifierError, "Unsupported modifier: #{s}"
end