Module: NXT::Utils::Accessors
- Included in:
- Command::Output, Connector::Output::Motor
- Defined in:
- lib/nxt/utils/accessors.rb
Instance Method Summary collapse
Instance Method Details
#attr_setter(name, options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nxt/utils/accessors.rb', line 4 def attr_setter(name, ) define_method("#{name}=") do |value| if .include?(:is) raise TypeError.new('Expected value to be a number') unless duration.is_a?([:is]) end if .include?(:is_key_in) && ![:is_key_in].include?(value) raise TypeError.new("Expected value to be one of: :#{[:is_key_in].keys.join(', :')}") end instance_variable_set("@#{name}", value) self end end |