Class: PiDriver::Utils::ArgumentHelper
- Inherits:
-
Object
- Object
- PiDriver::Utils::ArgumentHelper
- Defined in:
- lib/pi_driver/utils/argument_helper.rb
Instance Attribute Summary collapse
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
Instance Method Summary collapse
- #check(type, arg, valid_options) ⇒ Object
-
#initialize(options = {}) ⇒ ArgumentHelper
constructor
A new instance of ArgumentHelper.
Constructor Details
#initialize(options = {}) ⇒ ArgumentHelper
Returns a new instance of ArgumentHelper.
6 7 8 9 |
# File 'lib/pi_driver/utils/argument_helper.rb', line 6 def initialize( = {}) @prefix = [:prefix] @suffix = [:suffix] end |
Instance Attribute Details
#prefix ⇒ Object
Returns the value of attribute prefix.
4 5 6 |
# File 'lib/pi_driver/utils/argument_helper.rb', line 4 def prefix @prefix end |
#suffix ⇒ Object
Returns the value of attribute suffix.
4 5 6 |
# File 'lib/pi_driver/utils/argument_helper.rb', line 4 def suffix @suffix end |
Instance Method Details
#check(type, arg, valid_options) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/pi_driver/utils/argument_helper.rb', line 11 def check(type, arg, ) return if .include?(arg) = .map(&:to_s).join(', ') middle = "invalid argument for #{type.inspect}, " middle += "#{arg.inspect} was given but expected to be one of #{}" = "#{@prefix if @prefix} #{middle} #{@suffix if @suffix}" raise ArgumentError, end |