Module: JamfRubyExtensions::Array::Utils
- Included in:
- Array
- Defined in:
- lib/jamf/ruby_extensions/array/utils.rb
Overview
Useful monkey patches for Array
Instance Method Summary collapse
-
#j_ci_fetch(somestring) ⇒ String?
(also: #jss_ci_fetch_string)
Fetch a string from an Array case-insensitively, e.g.
Instance Method Details
#j_ci_fetch(somestring) ⇒ String? Also known as: jss_ci_fetch_string
Fetch a string from an Array case-insensitively, e.g. if my_array contains ‘thrasher’,
my_array.j_ci_fetch('ThRashEr')
will return ‘thrasher’
returns nil if no match
43 44 45 46 |
# File 'lib/jamf/ruby_extensions/array/utils.rb', line 43 def j_ci_fetch(somestring) each { |s| return s if s.respond_to?(:casecmp?) && s.casecmp?(somestring) } nil end |