summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-symbol-ext/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-04-20 21:30:46 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-04-20 21:30:46 +0900
commita6941101933a06e234f57a180d7119eafa9f1904 (patch)
tree192aead21f0cab7a50d0d5c9ef5518ad3278013c /mrbgems/mruby-symbol-ext/mrblib
parenta6d8df6761a0c84f0cd275a709050c187f60b35f (diff)
parentbb52324bd95628b75925693340577d4390a2c564 (diff)
downloadmruby-a6941101933a06e234f57a180d7119eafa9f1904.tar.gz
mruby-a6941101933a06e234f57a180d7119eafa9f1904.zip
Merge pull request #2089 from ksss/sym-casecmp
Implement Symbol#casecmp
Diffstat (limited to 'mrbgems/mruby-symbol-ext/mrblib')
-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 51a8ddc84..f4bf23cb1 100644
--- a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
+++ b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
@@ -48,6 +48,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