Module: Wesabe::Util
Instance Method Summary collapse
-
#all_or_one(what) {|element| ... } ⇒ Array<Object>, Object
Yields
what
or, ifwhat
is an array, each element ofwhat
.
Instance Method Details
#all_or_one(what) {|element| ... } ⇒ Array<Object>, Object
Yields what
or, if what
is an array, each element of what
. It’s sort of like an argument-agnostic map
.
12 13 14 15 |
# File 'lib/wesabe/util.rb', line 12 def all_or_one(what, &block) result = Array(what).each(&block) return what.is_a?(Array) ? result : result.first end |