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.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
index 4cf18f647..acb2a562c 100644
--- a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
+++ b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb
@@ -9,23 +9,12 @@ class Symbol
##
# call-seq:
- # sym.length -> integer
- #
- # Same as <code>sym.to_s.length</code>.
-
- def length
- self.to_s.length
- end
- alias :size :length
-
- ##
- # call-seq:
# sym.capitalize -> symbol
#
# Same as <code>sym.to_s.capitalize.intern</code>.
def capitalize
- self.to_s.capitalize.intern
+ (self.to_s.capitalize! || self).to_sym
end
##
@@ -35,7 +24,7 @@ class Symbol
# Same as <code>sym.to_s.downcase.intern</code>.
def downcase
- self.to_s.downcase.intern
+ (self.to_s.downcase! || self).to_sym
end
##
@@ -45,7 +34,7 @@ class Symbol
# Same as <code>sym.to_s.upcase.intern</code>.
def upcase
- self.to_s.upcase.intern
+ (self.to_s.upcase! || self).to_sym
end
##
@@ -56,7 +45,9 @@ class Symbol
def casecmp(other)
return nil unless other.kind_of?(Symbol)
- self.to_s.upcase <=> other.to_s.upcase
+ lhs = self.to_s; lhs.upcase!
+ rhs = other.to_s; rhs.upcase!
+ lhs <=> rhs
end
#
@@ -66,7 +57,7 @@ class Symbol
# Returns that _sym_ is :"" or not.
def empty?
- self.to_s.empty?
+ self.length == 0
end
end