Class: Array
Overview
Extend Array with some helper methods.
Instance Method Summary collapse
-
#all_present? ⇒ Boolean
Returns true if all elements are present, false if one is nil.
-
#each_present? ⇒ Boolean
Returns an array with a boolean representing each element’s presence.
-
#mask_present ⇒ Object
Replaces non-nil elements with present.
Instance Method Details
#all_present? ⇒ Boolean
Returns true if all elements are present, false if one is nil
75 76 77 78 79 80 |
# File 'lib/tektite_ruby_utils/present.rb', line 75 def all_present? each do |e| return false if e.nil? end true end |
#each_present? ⇒ Boolean
Returns an array with a boolean representing each element’s presence
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/tektite_ruby_utils/present.rb', line 83 def each_present? result = [] each_with_index do |e, i| result[i] = if e.nil? false else true end end result end |