Skip to content

Commit 4977ec3

Browse files
committed
Adds doc
1 parent 4344ae5 commit 4977ec3

File tree

1 file changed

+76
-76
lines changed

1 file changed

+76
-76
lines changed

README.md

+76-76
Original file line numberDiff line numberDiff line change
@@ -23,127 +23,127 @@ methods like `match?` or `include?`, `empty?` use `_` instead of `?`.
2323
```js
2424
"Ho! ".x(3) //=> "Ho! Ho! Ho! "
2525

26-
"hello".capitalize() #=> "Hello"
26+
"hello".capitalize() //=> "Hello"
2727

28-
"abcdef".casecmp("abcde") #=> 1
29-
"aBcDeF".casecmp("abcdef") #=> 0
30-
"abcdef".casecmp("abcdefg") #=> -1
31-
"abcdef".casecmp("ABCDEF") #=> 0
28+
"abcdef".casecmp("abcde") //=> 1
29+
"aBcDeF".casecmp("abcdef") //=> 0
30+
"abcdef".casecmp("abcdefg") //=> -1
31+
"abcdef".casecmp("ABCDEF") //=> 0
3232

3333

3434

35-
"abcdef".casecmp_("abcde") #=> false
36-
"aBcDeF".casecmp_("abcdef") #=> true
37-
"abcdef".casecmp_("abcdefg") #=> false
38-
"abcdef".casecmp_("ABCDEF") #=> true
35+
"abcdef".casecmp_("abcde") //=> false
36+
"aBcDeF".casecmp_("abcdef") //=> true
37+
"abcdef".casecmp_("abcdefg") //=> false
38+
"abcdef".casecmp_("ABCDEF") //=> true
3939

4040

4141

42-
"hello".center(4) #=> "hello"
43-
"hello".center(20) #=> " hello "
44-
"hello".center(20, '123') #=> "1231231hello12312312"
42+
"hello".center(4) //=> "hello"
43+
"hello".center(20) //=> " hello "
44+
"hello".center(20, '123') //=> "1231231hello12312312"
4545

4646

47-
"abcde".chr() #=> "a"
47+
"abcde".chr() //=> "a"
4848

49-
"hEllO".downcase() #=> "hello"
50-
"hEllO".upcase() #=> "HELLO"
49+
"hEllO".downcase() //=> "hello"
50+
"hEllO".upcase() //=> "HELLO"
5151

5252

5353
"hello".each_char(function(c){ console.log(c, ' ') })
5454
produces:
5555

5656
h e l l o
5757

58-
"hello".empty_ #=> false
59-
" ".empty _ #=> false
60-
"".empty_ #=> true
58+
"hello".empty_ //=> false
59+
" ".empty _ //=> false
60+
"".empty_ //=> true
6161

6262

63-
"hello".end_with_("ello") #=> true
63+
"hello".end_with_("ello") //=> true
6464

6565
# returns true if one of the +suffixes+ matches.
66-
"hello".end_with_("heaven", "ello") #=> true
67-
"hello".end_with_("heaven", "paradise") #=> false
66+
"hello".end_with_("heaven", "ello") //=> true
67+
"hello".end_with_("heaven", "paradise") //=> false
6868

6969

70-
"hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
71-
"hello".gsub(/([aeiou])/, '<\1>') #=> "h<e>ll<o>"
70+
"hello".gsub(/[aeiou]/, '*') //=> "h*ll*"
71+
"hello".gsub(/([aeiou])/, '<\1>') //=> "h<e>ll<o>"
7272

73-
"hello".include_("lo") #=> true
74-
"hello".include_("ol") #=> false
75-
"hello".include_('h') #=> true
73+
"hello".include_("lo") //=> true
74+
"hello".include_("ol") //=> false
75+
"hello".include_('h') //=> true
7676

77-
"hello".index('e') #=> 1
78-
"hello".index('lo') #=> 3
79-
"hello".index('a') #=> nil
80-
"hello".index('e') #=> 1
77+
"hello".index('e') //=> 1
78+
"hello".index('lo') //=> 3
79+
"hello".index('a') //=> nil
80+
"hello".index('e') //=> 1
8181

82-
"hello\nworld\n".lines() #=> ["hello\n", "world\n"]
83-
"hello world".lines(' ') #=> ["hello ", " ", "world"]
84-
"hello\nworld\n".lines() #=> ["hello", "world"]
82+
"hello\nworld\n".lines() //=> ["hello\n", "world\n"]
83+
"hello world".lines(' ') //=> ["hello ", " ", "world"]
84+
"hello\nworld\n".lines() //=> ["hello", "world"]
8585

86-
" hello ".lstrip() #=> "hello "
87-
"hello".lstrip() #=> "hello"
86+
" hello ".lstrip() //=> "hello "
87+
"hello".lstrip() //=> "hello"
8888

89-
" hello ".rstrip() #=> " hello"
90-
"hello".rstrip() #=> "hello"
89+
" hello ".rstrip() //=> " hello"
90+
"hello".rstrip() //=> "hello"
9191

9292

93-
"Ruby".match_(/R.../) #=> true
94-
"Ruby".match_(/R.../, 1) #=> false
95-
"Ruby".match_(/P.../) #=> false
93+
"Ruby".match_(/R.../) //=> true
94+
"Ruby".match_(/R.../, 1) //=> false
95+
"Ruby".match_(/P.../) //=> false
9696

97-
"abcd".succ() #=> "abce"
98-
"THX1138".succ() #=> "THX1139"
97+
"abcd".succ() //=> "abce"
98+
"THX1138".succ() //=> "THX1139"
9999
"<<koala>>".succ()
100100

101-
"abcd".next() #=> "abce"
102-
"THX1138".next() #=> "THX1139"
103-
"<<koala>>".next() #=> "<<koalb>>"
101+
"abcd".next() //=> "abce"
102+
"THX1138".next() //=> "THX1139"
103+
"<<koala>>".next() //=> "<<koalb>>"
104104

105-
"a".ord() #=> 49
105+
"a".ord() //=> 49
106106

107107
// Non mutative
108108
a = "!"
109-
a.prepend("hello ", "world") #=> "hello world!"
109+
a.prepend("hello ", "world") //=> "hello world!"
110110

111-
"stressed".reverse() #=> "desserts"
111+
"stressed".reverse() //=> "desserts"
112112

113113
a = "cruel world"
114-
a.scan(/\w+/) #=> ["cruel", "world"]
115-
a.scan(/.../) #=> ["cru", "el ", "wor"]
116-
a.scan(/(...)/) #=> [["cru"], ["el "], ["wor"]]
117-
a.scan(/(..)(..)/) #=> [["cr", "ue"], ["l ", "wo"]]
114+
a.scan(/\w+/) //=> ["cruel", "world"]
115+
a.scan(/.../) //=> ["cru", "el ", "wor"]
116+
a.scan(/(...)/) //=> [["cru"], ["el "], ["wor"]]
117+
a.scan(/(..)(..)/) //=> [["cr", "ue"], ["l ", "wo"]]
118118

119-
"cruel world".size() #=> 11
119+
"cruel world".size() //=> 11
120120

121121

122-
"hello".start_with_("hell") #=> true
123-
"hello".start_with_(/H/i) #=> true
122+
"hello".start_with_("hell") //=> true
123+
"hello".start_with_(/H/i) //=> true
124124

125125
# returns true if one of the prefixes matches.
126-
"hello".start_with_"heaven", "hell") #=> true
127-
"hello".start_with_("heaven", "paradise") #=> false
128-
129-
"hello".sub(/[aeiou]/, '*') #=> "h*llo"
130-
131-
"Hello".swapcase() #=> "hELLO"
132-
"cYbEr_PuNk11".swapcase() #=> "CyBeR_pUnK11"
133-
134-
"123.45e1".to_f() #=> 1234.5
135-
"45.67 degrees".to_f() #=> 45.67
136-
"thx1138".to_f() #=> 0.0
137-
138-
"12345".to_i #=> 12345
139-
"99 red balloons".to_i #=> 99
140-
"0a".to_i #=> 0
141-
"0a".to_i(16) #=> 10
142-
"hello".to_i #=> 0
143-
"1100101".to_i(2) #=> 101
144-
"1100101".to_i(8) #=> 294977
145-
"1100101".to_i(10) #=> 1100101
146-
"1100101".to_i(16) #=> 17826049
126+
"hello".start_with_"heaven", "hell") //=> true
127+
"hello".start_with_("heaven", "paradise") //=> false
128+
129+
"hello".sub(/[aeiou]/, '*') //=> "h*llo"
130+
131+
"Hello".swapcase() //=> "hELLO"
132+
"cYbEr_PuNk11".swapcase() //=> "CyBeR_pUnK11"
133+
134+
"123.45e1".to_f() //=> 1234.5
135+
"45.67 degrees".to_f() //=> 45.67
136+
"thx1138".to_f() //=> 0.0
137+
138+
"12345".to_i //=> 12345
139+
"99 red balloons".to_i //=> 99
140+
"0a".to_i //=> 0
141+
"0a".to_i(16) //=> 10
142+
"hello".to_i //=> 0
143+
"1100101".to_i(2) //=> 101
144+
"1100101".to_i(8) //=> 294977
145+
"1100101".to_i(10) //=> 1100101
146+
"1100101".to_i(16) //=> 17826049
147147

148148
```
149149

0 commit comments

Comments
 (0)