Class: Array
- Defined in:
- lib/jamf/ruby_extensions/dig.rb,
lib/jss/compatibility.rb,
lib/jamf/compatibility.rb,
lib/jss/ruby_extensions/array.rb,
lib/jamf/ruby_extensions/array.rb
Overview
an array
Instance Method Summary collapse
- #dig(key, *rest) ⇒ Object included from RubyDig
-
#j_ci_fetch(somestring) ⇒ String?
included
from JamfRubyExtensions::Array::Utils
Fetch a string from an Array case-insensitively, e.g.
-
#j_ci_include?(somestring) ⇒ Boolean
included
from JamfRubyExtensions::Array::Utils
case-insensitive version of include?.
-
#j_ci_include_string?(somestring) ⇒ Boolean
included
from JamfRubyExtensions::Array::Predicates
A case-insensitive version of #include? for Arrays of Strings.
-
#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
#j_ci_fetch(somestring) ⇒ String? Originally defined in module JamfRubyExtensions::Array::Utils
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
#j_ci_include?(somestring) ⇒ Boolean Originally defined in module JamfRubyExtensions::Array::Utils
case-insensitive version of include?
#j_ci_include_string?(somestring) ⇒ Boolean Originally defined in module JamfRubyExtensions::Array::Predicates
A case-insensitive version of #include? for Arrays of Strings.
#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 |