Module: Vpim::Methods
- Defined in:
- lib/vpim/vpim.rb
Overview
:nodoc:
Class Method Summary collapse
-
.casecmp?(str0, str1) ⇒ Boolean
Case-insensitive comparison of
str0
tostr1
, returns true or false.
Class Method Details
.casecmp?(str0, str1) ⇒ Boolean
Case-insensitive comparison of str0
to str1
, returns true or false. Either argument can be nil, where nil compares not equal to anything other than nil.
This is available both as a module function:
Vpim::Methods.casecmp?("yes", "YES")
and an instance method:
include Vpim::Methods
casecmp?("yes", "YES")
Will work with ruby1.6 and ruby 1.8.
TODO - could make this be more efficient, but I’m supporting 1.6, not optimizing for it.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vpim/vpim.rb', line 49 def casecmp?(str0, str1) if str0 == nil if str1 == nil return true else return false end end begin str0.casecmp(str1) == 0 rescue NoMethodError str0.downcase == str1.downcase end end |