summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-symbol-ext/mrblib/symbol.rb')
-rw-r--r--mrbgems/mruby-symbol-ext/mrblib/symbol.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
index 78edf3cad..e38ee468d 100644
--- a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
+++ b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
@@ -47,6 +47,17 @@ class Symbol
self.to_s.upcase.intern
end
+ ##
+ # call-seq:
+ # sym.casecmp(other) -> -1, 0, +1 or nil
+ #
+ # Case-insensitive version of <code>Symbol#<=></code>.
+
+ def casecmp(other)
+ return nil unless other.kind_of?(Symbol)
+ self.to_s.upcase <=> other.to_s.upcase
+ end
+
#
# call-seq:
# sym.empty? -> true or false