diff options
| author | YAMAMOTO Masaya <[email protected]> | 2017-11-04 01:23:12 +0900 |
|---|---|---|
| committer | YAMAMOTO Masaya <[email protected]> | 2017-11-04 01:23:12 +0900 |
| commit | 625f9f6fa314872968632c5adbee7fb3823268b8 (patch) | |
| tree | fdde1700b13048212606e4a995907f3757e18e2f /mrbgems/mruby-symbol-ext | |
| parent | b70d69de09130ce2bc89289b4826b3deea8afaae (diff) | |
| parent | e7fe6ee2638dee438c1d79ab16a0403aebec0a60 (diff) | |
| download | mruby-625f9f6fa314872968632c5adbee7fb3823268b8.tar.gz mruby-625f9f6fa314872968632c5adbee7fb3823268b8.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'mrbgems/mruby-symbol-ext')
| -rw-r--r-- | mrbgems/mruby-symbol-ext/mrblib/symbol.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb index 1e3d24b80..28cce3156 100644 --- a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +++ b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb @@ -48,10 +48,23 @@ class Symbol def casecmp(other) return nil unless other.kind_of?(Symbol) lhs = self.to_s; lhs.upcase! - rhs = other.to_s; rhs.upcase! + rhs = other.to_s.upcase lhs <=> rhs end + ## + # call-seq: + # sym.casecmp?(other) -> true, false, or nil + # + # Returns true if sym and other_sym are equal after case folding, + # false if they are not equal, and nil if other_sym is not a string. + + def casecmp?(sym) + c = self.casecmp(sym) + return nil if c.nil? + return c == 0 + end + # # call-seq: # sym.empty? -> true or false |
