summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/mrblib/string.rb
diff options
context:
space:
mode:
authorSeba Gamboa <[email protected]>2015-10-14 14:37:47 -0300
committerSeba Gamboa <[email protected]>2015-10-20 12:16:47 -0300
commit5cdcce8dbddd94ecb9503a0a1d47370c4ef97177 (patch)
tree07dae36bc4e2762a8d420fbea2e67b4a087ea260 /mrbgems/mruby-string-ext/mrblib/string.rb
parent84b70886cd9827593810264bf1f068044d5c6986 (diff)
downloadmruby-5cdcce8dbddd94ecb9503a0a1d47370c4ef97177.tar.gz
mruby-5cdcce8dbddd94ecb9503a0a1d47370c4ef97177.zip
Mark core gems with mrbgem tag
Diffstat (limited to 'mrbgems/mruby-string-ext/mrblib/string.rb')
-rw-r--r--mrbgems/mruby-string-ext/mrblib/string.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb
index 4c8a2ce3b..b38b3c59f 100644
--- a/mrbgems/mruby-string-ext/mrblib/string.rb
+++ b/mrbgems/mruby-string-ext/mrblib/string.rb
@@ -9,6 +9,7 @@ class String
# a = "abcde"
# a.clear #=> ""
#
+ # @mrbgem mruby-string-ext
def clear
self.replace("")
end
@@ -23,6 +24,7 @@ class String
# " hello ".lstrip #=> "hello "
# "hello".lstrip #=> "hello"
#
+ # @mrbgem mruby-string-ext
def lstrip
a = 0
z = self.size - 1
@@ -40,6 +42,7 @@ class String
# " hello ".rstrip #=> " hello"
# "hello".rstrip #=> "hello"
#
+ # @mrbgem mruby-string-ext
def rstrip
a = 0
z = self.size - 1
@@ -56,6 +59,7 @@ class String
# " hello ".strip #=> "hello"
# "\tgoodbye\r\n".strip #=> "goodbye"
#
+ # @mrbgem mruby-string-ext
def strip
a = 0
z = self.size - 1
@@ -75,6 +79,7 @@ class String
# " hello ".lstrip #=> "hello "
# "hello".lstrip! #=> nil
#
+ # @mrbgem mruby-string-ext
def lstrip!
s = self.lstrip
(s == self) ? nil : self.replace(s)
@@ -91,6 +96,7 @@ class String
# " hello ".rstrip #=> " hello"
# "hello".rstrip! #=> nil
#
+ # @mrbgem mruby-string-ext
def rstrip!
s = self.rstrip
(s == self) ? nil : self.replace(s)
@@ -103,6 +109,7 @@ class String
# Removes leading and trailing whitespace from <i>str</i>. Returns
# <code>nil</code> if <i>str</i> was not altered.
#
+ # @mrbgem mruby-string-ext
def strip!
s = self.strip
(s == self) ? nil : self.replace(s)
@@ -119,6 +126,7 @@ class String
# "abcdef".casecmp("abcdefg") #=> -1
# "abcdef".casecmp("ABCDEF") #=> 0
#
+ # @mrbgem mruby-string-ext
def casecmp(str)
self.downcase <=> str.to_str.downcase
rescue NoMethodError
@@ -136,6 +144,7 @@ class String
end
end
+ # @mrbgem mruby-string-ext
def rpartition(sep)
raise TypeError, "type mismatch: #{sep.class} given" unless sep.is_a? String
n = rindex(sep)
@@ -163,6 +172,7 @@ class String
# string.slice!("r") #=> "r"
# string #=> "thsa sting"
#
+ # @mrbgem mruby-string-ext
def slice!(arg1, arg2=nil)
raise "wrong number of arguments (for 1..2)" if arg1.nil? && arg2.nil?
@@ -234,6 +244,7 @@ class String
# "abcd".insert(-3, 'X') #=> "abXcd"
# "abcd".insert(-1, 'X') #=> "abcdX"
#
+ # @mrbgem mruby-string-ext
def insert(idx, str)
pos = idx.to_i
pos += self.size + 1 if pos < 0
@@ -256,6 +267,8 @@ class String
# "hello".ljust(4) #=> "hello"
# "hello".ljust(20) #=> "hello "
# "hello".ljust(20, '1234') #=> "hello123412341234123"
+ #
+ # @mrbgem mruby-string-ext
def ljust(idx, padstr = ' ')
if idx <= self.size
return self
@@ -297,6 +310,7 @@ class String
# "25".upto("5").to_a #=> []
# "07".upto("11").to_a #=> ["07", "08", "09", "10", "11"]
#
+ # @mrbgem mruby-string-ext
def upto(other_str, excl=false, &block)
return to_enum :upto, other_str, excl unless block
@@ -311,6 +325,7 @@ class String
end
end
+ # @mrbgem mruby-string-ext
def chars(&block)
if block_given?
self.split('').map do |i|
@@ -323,6 +338,7 @@ class String
end
alias each_char chars
+ # @mrbgem mruby-string-ext
def codepoints(&block)
len = self.size