Class: ChinoRuby::CheckValues
- Inherits:
-
Object
- Object
- ChinoRuby::CheckValues
- Defined in:
- lib/chino_ruby/classes.rb
Direct Known Subclasses
ChinoAPI, Blob, ChinoBaseAPI, Field, FilterOption, GetBlobResponse, InitBlobResponse, SortOption
Instance Method Summary collapse
-
#check_boolean(value) ⇒ Object
This function is used to check if a parameter passed to a function is a boolean, otherwise it raises an error.
-
#check_int(value) ⇒ Object
This function is used to check if a parameter passed to a function is an integer, otherwise it raises an error.
-
#check_json(value) ⇒ Object
This function is used to check if a parameter passed to a function can be converted to json, otherwise it raises an error.
-
#check_string(value) ⇒ Object
This function is used to check if a parameter passed to a function is a string, otherwise it raises an error.
Instance Method Details
#check_boolean(value) ⇒ Object
This function is used to check if a parameter passed to a function is a boolean, otherwise it raises an error
22 23 24 25 26 |
# File 'lib/chino_ruby/classes.rb', line 22 def check_boolean(value) if not !!value == value raise ArgumentError, "{#value} must be a Boolean, got #{value.inspect}" end end |
#check_int(value) ⇒ Object
This function is used to check if a parameter passed to a function is an integer, otherwise it raises an error
15 16 17 18 19 |
# File 'lib/chino_ruby/classes.rb', line 15 def check_int(value) if not value.is_a?(Integer) raise ArgumentError, "{#value} must be a Int, got #{value.inspect}" end end |
#check_json(value) ⇒ Object
This function is used to check if a parameter passed to a function can be converted to json, otherwise it raises an error
29 30 31 32 33 |
# File 'lib/chino_ruby/classes.rb', line 29 def check_json(value) if not value.respond_to?(:to_json) raise ArgumentError, "{#value} cannot be converted to json!" end end |
#check_string(value) ⇒ Object
This function is used to check if a parameter passed to a function is a string, otherwise it raises an error
8 9 10 11 12 |
# File 'lib/chino_ruby/classes.rb', line 8 def check_string(value) if not value.is_a?(String) raise ArgumentError, "{#value} must be a String, got #{value.inspect}" end end |