Class: JsonRpcObjects::Utils::Object
- Inherits:
-
Object
- Object
- JsonRpcObjects::Utils::Object
- Defined in:
- lib/json-rpc-objects/utils/object.rb
Overview
Object utility functions.
Class Method Summary collapse
-
.boolean?(object) ⇒ Boolean
Indicates, object is boolean.
-
.instance_of_any?(object, *classes) ⇒ Boolean
Returns
true
if object is an instance of the given classes. -
.kind_of_any?(object, *classes) ⇒ Boolean
Returns
true
if one of classes are the class of object, or if one of classes are one of the superclasses of object or modules included in object.
Class Method Details
.boolean?(object) ⇒ Boolean
Indicates, object is boolean.
78 79 80 |
# File 'lib/json-rpc-objects/utils/object.rb', line 78 def self.boolean?(object) self.instance_of_any? object, [TrueClass, FalseClass] end |
.instance_of_any?(object, *classes) ⇒ Boolean
Returns true
if object is an instance of the given classes.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/json-rpc-objects/utils/object.rb', line 32 def self.instance_of_any?(object, *classes) if classes.first.kind_of? ::Array classes = classes.first end classes.each do |cls| if object.instance_of? cls return true end end return false end |
.kind_of_any?(object, *classes) ⇒ Boolean
Returns true
if one of classes are the class of object, or if one of classes are one of the superclasses of object or modules included in object.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/json-rpc-objects/utils/object.rb', line 57 def self.kind_of_any?(object, *classes) if classes.first.kind_of? ::Array classes = classes.first end classes.each do |cls| if object.kind_of? cls return true end end return false end |