種類
- インスタンスメソッド (1984)
- 特異メソッド (35)
ライブラリ
- ビルトイン (1797)
-
bigdecimal
/ util (10) - csv (10)
- kconv (120)
- rake (50)
- scanf (12)
- shellwords (20)
キーワード
- % (10)
- * (10)
- + (10)
- +@ (8)
- -@ (8)
- << (10)
- <=> (10)
- == (10)
- === (10)
- =~ (10)
- [] (60)
- []= (70)
-
ascii
_ only? (10) - b (10)
- byteindex (1)
- byterindex (1)
- bytes (20)
- bytesize (10)
- byteslice (30)
- bytesplice (2)
- capitalize (10)
- capitalize! (10)
- casecmp (10)
- casecmp? (7)
- center (10)
- chars (20)
- chomp (10)
- chomp! (10)
- chop (10)
- chop! (10)
- chr (10)
- clear (10)
- codepoints (20)
- concat (17)
- count (10)
- crypt (10)
- dedup (1)
- delete (10)
- delete! (10)
-
delete
_ prefix (6) -
delete
_ prefix! (6) -
delete
_ suffix (6) -
delete
_ suffix! (6) - downcase (10)
- downcase! (10)
- dump (10)
-
each
_ byte (20) -
each
_ char (20) -
each
_ codepoint (20) -
each
_ grapheme _ cluster (12) -
each
_ line (20) - empty? (10)
- encode (30)
- encode! (20)
- encoding (10)
-
end
_ with? (10) - eql? (10)
- ext (10)
-
force
_ encoding (10) - getbyte (10)
-
grapheme
_ clusters (12) - gsub (40)
- gsub! (40)
- hash (10)
- hex (10)
- include? (10)
- index (10)
- insert (10)
- inspect (10)
- intern (10)
- iseuc (10)
- isjis (10)
- issjis (10)
- isutf8 (10)
- kconv (10)
- length (10)
- lines (20)
- ljust (10)
- lstrip (10)
- lstrip! (10)
- match (20)
- match? (7)
- new (25)
- next (10)
- next! (10)
- oct (10)
- ord (10)
-
parse
_ csv (10) - partition (10)
- pathmap (10)
-
pathmap
_ explode (10) -
pathmap
_ partial (10) -
pathmap
_ replace (10) - prepend (17)
- replace (10)
- reverse (10)
- reverse! (10)
- rindex (10)
- rjust (10)
- rpartition (10)
- rstrip (10)
- rstrip! (10)
- scan (20)
- scanf (12)
- scrub (30)
- scrub! (30)
- setbyte (10)
- shellescape (10)
- shellsplit (10)
- size (10)
- slice (60)
- slice! (60)
- split (15)
- squeeze (10)
- squeeze! (10)
-
start
_ with? (10) - strip (10)
- strip! (10)
- sub (30)
- sub! (30)
- succ (10)
- succ! (10)
- sum (10)
- swapcase (10)
- swapcase! (10)
-
to
_ c (10) -
to
_ d (10) -
to
_ f (10) -
to
_ i (10) -
to
_ r (10) -
to
_ s (10) -
to
_ str (10) -
to
_ sym (10) - toeuc (10)
- tojis (10)
- tolocale (10)
- tosjis (10)
- toutf16 (10)
- toutf32 (10)
- toutf8 (10)
- tr (10)
- tr! (10)
-
tr
_ s (10) -
tr
_ s! (10) -
try
_ convert (10) - undump (6)
-
unicode
_ normalize (9) -
unicode
_ normalize! (9) -
unicode
_ normalized? (9) - unpack (10)
- unpack1 (7)
- upcase (10)
- upcase! (10)
- upto (10)
-
valid
_ encoding? (10)
検索結果
先頭5件
-
String
# %(args) -> String (1.0) -
printf と同じ規則に従って args をフォーマットします。
...sprintf("%c", 'a') #=> "a"
//}
フラグ `-' と幅 の指定だけが意味を持ちます。
: s
文字列を出力します。
引数が String オブジェクトでなければ to_s メソッドにより文字列化
したものを引数として扱います。
: p
Object#inspect の... -
String
# *(times) -> String (1.0) -
文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。
文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。
@param times 整数
@return self を times 回繰り返した新しい文字列
@raise ArgumentError 引数に負数を指定したときに発生します。
//emlist[例][ruby]{
p "str" * 3 # => "strstrstr"
str = "abc"
p str * 4 # => "abcabcabcabc"
p str * 0 # => ""
p str # => "abc" (変化なし)
//} -
String
# +(other) -> String (1.0) -
文字列と other を連結した新しい文字列を返します。
...er を連結した新しい文字列を返します。
@param other 文字列
@return self と other を連結した文字列
//emlist[例][ruby]{
p "str" + "ing" # => "string"
a = "abc"
b = "def"
p a + b # => "abcdef"
p a # => "abc" (変化なし)
p b # => "def"
//}... -
String
# +@ -> String | self (1.0) -
self が freeze されている文字列の場合、元の文字列の複製を返します。 freeze されていない場合は self を返します。
...の場合、元の文字列の複製を返します。
freeze されていない場合は self を返します。
//emlist[例][ruby]{
# frozen_string_literal: false
original_text = "text"
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_tex......t # => true
original_text.equal?(unfrozen_text) # => true
original_text = "text".freeze
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => false
//}
@see String#-@... -
String
# -@ -> String | self (1.0) -
self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。
...されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。
//emlist[例][ruby]{
# frozen_string_literal: false
original_text = "text"
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text......# => true
original_text.equal?(frozen_text) # => false
original_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
//}
@see String#+@... -
String
# <<(other) -> self (1.0) -
self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。
...追加します。
self を返します。
@param other 文字列もしくは 0 以上の整数
//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "stringXXX"
str << "YYY"
p str # => "stringXXXYYY"
str << 65 # 文字AのASCIIコード
p str # => "stringXXXYYYA"
//}... -
String
# <=>(other) -> -1 | 0 | 1 | nil (1.0) -
self と other を ASCII コード順で比較して、 self が大きい時には 1、等しい時には 0、小さい時には -1 を返します。 このメソッドは Comparable モジュールのメソッドを実装するために使われます。
...します。
@param other 文字列
@return 比較結果の整数か nil
//emlist[例][ruby]{
p "aaa" <=> "xxx" # => -1
p "aaa" <=> "aaa" # => 0
p "xxx" <=> "aaa" # => 1
p "string" <=> "stringAA" # => -1
p "string" <=> "string" # => 0
p "stringAA" <=> "string" # => 1
//}... -
String
# ==(other) -> bool (1.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false......st[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
String
# ===(other) -> bool (1.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false......st[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
String
# =~(other) -> Integer | nil (1.0) -
正規表現 other とのマッチを行います。 マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。
...が設定されます。
@param other 正規表現もしくは =~ メソッドを持つオブジェクト
@raise TypeError other が文字列の場合に発生します。
//emlist[例][ruby]{
p "string" =~ /str/ # => 0
p "string" =~ /not/ # => nil
p "abcfoo" =~ /foo/ # => 3
//}... -
String
# [](nth) -> String | nil (1.0) -
nth 番目の文字を返します。 nth が負の場合は文字列の末尾から数えます。 つまり、 self.size + nth 番目の文字を返します。
...nth が範囲外を指す場合は nil を返します。
@param nth 文字の位置を表す整数
@return 指定した位置の文字を表す String オブジェクト
//emlist[例][ruby]{
p 'bar'[2] # => "r"
p 'bar'[2] == ?r # => true
p 'bar'[-1] # => "r"
p 'bar'[3] # => nil...