Class: UdooNeoRest::ValidateGpio

Inherits:
Validate
  • Object
show all
Defined in:
lib/udooneorest/validators.rb

Overview

Validate the GPIO parameter

value : the gpio value to be validated

Instance Attribute Summary

Attributes inherited from Validate

#error_message, #value

Instance Method Summary collapse

Methods inherited from Validate

#initialize

Constructor Details

This class inherits a constructor from UdooNeoRest::Validate

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
# File 'lib/udooneorest/validators.rb', line 51

def valid?
  unless GPIOS.include?(@value) && (@value != 'NA')
    @error_message = UdooNeoRest::Base.status_error("GPIO value of '#{@value}' is invalid. Should be one of #{(GPIOS - ['NA']).sort.join(',')}.")
    return false
  end

  @error_message  = nil
  true
end