Class: Array
- Defined in:
- lib/jss/compatibility.rb,
lib/jss/ruby_extensions/array.rb
Instance Method Summary collapse
-
#jss_ci_fetch_string(somestring) ⇒ String?
Fetch a string from an Array of Strings case-insensitively, e.g.
-
#jss_ci_include_string?(somestring) ⇒ Boolean
A case-insensitive version of #include? for Arrays of Strings.
Instance Method Details
#jss_ci_fetch_string(somestring) ⇒ String?
Fetch a string from an Array of Strings case-insensitively, e.g. my_array.jss_ci_fetch_string(‘ThRashEer’) will return ‘thrasher’ or nil if no match
47 48 49 50 |
# File 'lib/jss/ruby_extensions/array.rb', line 47 def jss_ci_fetch_string(somestring) idx = index { |s| s.to_s.casecmp(somestring).zero? } idx ? self[idx] : nil end |
#jss_ci_include_string?(somestring) ⇒ Boolean
A case-insensitive version of #include? for Arrays of Strings.
35 36 37 |
# File 'lib/jss/ruby_extensions/array.rb', line 35 def jss_ci_include_string?(somestring) any? { |s| s.to_s.casecmp(somestring).zero? } end |