class PiDriver::Utils::ArgumentHelper
Attributes
prefix[RW]
suffix[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/pi_driver/utils/argument_helper.rb, line 6 def initialize(options = {}) @prefix = options[:prefix] @suffix = options[:suffix] end
Public Instance Methods
check(type, arg, valid_options)
click to toggle source
# File lib/pi_driver/utils/argument_helper.rb, line 11 def check(type, arg, valid_options) return if valid_options.include?(arg) options = valid_options.map(&:to_s).join(', ') middle = "invalid argument for #{type.inspect}, " middle += "#{arg.inspect} was given but expected to be one of #{options}" message = "#{@prefix if @prefix} #{middle} #{@suffix if @suffix}" raise ArgumentError, message end