Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/motion_model/ext.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#has_hash_key?(key) ⇒ Boolean
If any item in the array has the key == ‘key` true, otherwise false.
-
#has_hash_value?(key) ⇒ Boolean
If any item in the array has the value == ‘key` true, otherwise false Of good use when writing specs.
Instance Method Details
#empty? ⇒ Boolean
214 215 216 |
# File 'lib/motion_model/ext.rb', line 214 def empty? self.length < 1 end |
#has_hash_key?(key) ⇒ Boolean
If any item in the array has the key == ‘key` true, otherwise false. Of good use when writing specs.
220 221 222 223 224 225 |
# File 'lib/motion_model/ext.rb', line 220 def has_hash_key?(key) self.each do |entity| return true if entity.has_key? key end return false end |
#has_hash_value?(key) ⇒ Boolean
If any item in the array has the value == ‘key` true, otherwise false Of good use when writing specs.
229 230 231 232 233 234 |
# File 'lib/motion_model/ext.rb', line 229 def has_hash_value?(key) self.each do |entity| entity.each_pair{|hash_key, value| return true if value == key} end return false end |