Method: JamfRubyExtensions::Array::Utils#j_ci_fetch
- Defined in:
- lib/jamf/ruby_extensions/array/utils.rb
#j_ci_fetch(somestring) ⇒ 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
42 43 44 45 46 |
# File 'lib/jamf/ruby_extensions/array/utils.rb', line 42 def j_ci_fetch(somestring) # select { |s| s&.casecmp? somestring }.first each { |s| return s if s&.casecmp?(somestring) } nil end |