クラス
-
ARGF
. class (121) - Array (96)
- Bignum (6)
- Binding (6)
- Complex (22)
- Data (8)
- Dir (130)
- Encoding (44)
-
Encoding
:: Converter (132) -
Encoding
:: InvalidByteSequenceError (11) -
Enumerator
:: ArithmeticSequence (6) -
Enumerator
:: Chain (6) - Exception (62)
- FalseClass (22)
- File (143)
-
File
:: Stat (22) - Fixnum (6)
- Float (22)
- Hash (22)
- IO (352)
- Integer (44)
- LoadError (11)
- MatchData (121)
- Method (22)
- Module (341)
- NameError (11)
- NilClass (6)
- Object (169)
- Proc (33)
-
Process
:: Status (22) - Random (11)
- Range (53)
- Rational (11)
- Refinement (3)
- Regexp (154)
- RubyVM (11)
-
RubyVM
:: AbstractSyntaxTree :: Node (6) -
RubyVM
:: InstructionSequence (66) - SignalException (11)
- String (1565)
- Struct (77)
- Symbol (176)
- SyntaxError (2)
- Thread (18)
-
Thread
:: Backtrace :: Location (33) - Time (60)
- TracePoint (50)
- TrueClass (11)
- UnboundMethod (55)
- UncaughtThrowError (10)
モジュール
- GC (11)
-
GC
:: Profiler (11) - Kernel (494)
- Marshal (44)
- Process (22)
-
RubyVM
:: AbstractSyntaxTree (8) - Signal (22)
キーワード
-
$ & (11) -
$ & # 39; (11) -
$ -F (11) -
$ -I (5) -
$ 1 (11) -
$ 10 (11) -
$ 11 (11) -
$ 2 (11) -
$ 3 (11) -
$ 4 (11) -
$ 5 (11) -
$ 6 (11) -
$ 7 (11) -
$ 8 (11) -
$ 9 (11) -
$ : (5) -
$ ; (11) -
$ LOAD _ PATH (11) -
$ PROGRAM _ NAME (11) -
$ ` (11) - % (23)
- * (33)
- + (11)
- << (11)
- <=> (22)
- == (22)
- === (33)
- =~ (48)
- Complex (11)
- Enumerator (11)
- Float (11)
- Integer (11)
- OPTS (22)
-
RUBY
_ COPYRIGHT (11) -
RUBY
_ DESCRIPTION (11) -
RUBY
_ ENGINE (11) -
RUBY
_ PLATFORM (11) - Regexp (11)
- Symbol (11)
- [] (154)
- []= (77)
-
_ dump (11) -
absolute
_ path (33) - argv0 (11)
- arity (11)
-
asciicompat
_ encoding (22) - asctime (11)
- autoload (22)
- autoload? (11)
- backtrace (11)
- basename (11)
- binread (11)
- binwrite (11)
- byteindex (2)
- byterindex (2)
- bytes (11)
- bytesize (11)
- bytesplice (6)
- caller (33)
- capitalize (22)
- capitalize! (11)
- captures (11)
- casecmp (22)
- casecmp? (16)
- center (11)
- children (20)
- chomp (22)
- chomp! (11)
- chop (22)
- chop! (11)
- chr (33)
- class (11)
-
class
_ variable _ get (11) -
class
_ variable _ set (11) - clear (11)
- clone (22)
- codepoints (22)
- compile (11)
-
compile
_ option (11) - concat (19)
-
const
_ defined? (11) -
const
_ get (11) -
const
_ source _ location (5) - count (11)
- cover? (12)
- crypt (11)
- ctime (11)
- dedup (2)
- define (4)
-
define
_ method (22) - delete (11)
- delete! (11)
-
delete
_ prefix (7) -
delete
_ prefix! (7) -
deprecate
_ constant (9) - dev (11)
- dirname (11)
- disasm (11)
- disassemble (11)
- downcase (19)
- downcase! (11)
- dump (33)
- dup (22)
-
each
_ byte (22) -
each
_ codepoint (22) -
each
_ grapheme _ cluster (14) -
each
_ line (22) - empty? (22)
- encode (33)
- encode! (22)
- entries (22)
- eql? (22)
-
error
_ bytes (11) - escape (11)
-
eval
_ script (6) - extname (11)
- find (11)
- finish (11)
-
for
_ fd (11) -
force
_ encoding (11) - format (11)
- freeze (11)
- ftype (22)
- getc (11)
- gets (59)
- glob (22)
-
grapheme
_ clusters (14) - gsub (77)
- gsub! (44)
- hash (11)
- hex (11)
- id2name (11)
-
import
_ methods (3) - index (11)
-
inplace
_ mode (11) - insert (11)
-
insert
_ output (11) - inspect (361)
- intern (11)
- join (11)
-
last
_ match (22) - lines (16)
- ljust (11)
- load (11)
-
locale
_ charmap (11) - lstrip (11)
- lstrip! (11)
- match (33)
- match? (16)
- method (11)
-
module
_ function (19) - name (15)
-
name
_ list (11) -
named
_ captures (11) - names (11)
- new (115)
- next (11)
- next! (11)
- oct (11)
- open (22)
- ord (11)
- pack (19)
- parse (8)
- partition (11)
- path (92)
-
post
_ match (11) -
pre
_ match (11) - pread (7)
- prepend (19)
- private (46)
-
private
_ class _ method (15) -
private
_ constant (11) -
private
_ method _ defined? (11) - protected (23)
-
protected
_ method _ defined? (11) - public (46)
-
public
_ class _ method (15) -
public
_ constant (11) -
public
_ instance _ method (11) -
public
_ method (11) -
public
_ method _ defined? (11) - putback (22)
- putc (11)
- pwd (11)
- pwrite (7)
- quote (11)
- read (55)
-
read
_ nonblock (20) - readchar (11)
- readline (35)
- readlines (77)
- readlink (11)
- readpartial (22)
- realdirpath (11)
- realpath (11)
-
remove
_ class _ variable (11) -
remove
_ const (11) - replace (11)
- replacement (11)
- replacement= (11)
- restore (11)
- result (11)
- reverse (11)
- reverse! (11)
- rindex (11)
- rjust (11)
- rpartition (11)
- rstrip (11)
- rstrip! (11)
- scan (22)
- scrub (11)
- scrub! (11)
-
set
_ backtrace (11) -
set
_ encoding (44) - setproctitle (11)
- signm (11)
- slice (77)
- slice! (22)
- source (11)
-
source
_ location (17) - split (28)
- sprintf (11)
- squeeze (11)
- squeeze! (11)
-
start
_ with? (12) - step (18)
- strftime (11)
- strip (11)
- strip! (11)
- sub (55)
- sub! (33)
- succ (11)
- succ! (11)
- swapcase (22)
- swapcase! (11)
- sysread (11)
- tainted? (6)
-
to
_ a (11) -
to
_ c (11) -
to
_ f (11) -
to
_ i (11) -
to
_ path (24) -
to
_ s (245) -
to
_ str (22) -
to
_ sym (11) - tr (11)
- tr! (11)
-
tr
_ s (11) -
tr
_ s! (11) - trace (11)
-
trace
_ var (33) - trap (44)
- undump (7)
- union (11)
- unpack (11)
- unpack1 (8)
-
untrace
_ var (11) - upcase (22)
- upcase! (11)
- upto (11)
-
values
_ at (22) - write (22)
-
write
_ nonblock (11) - zone (11)
検索結果
先頭5件
-
String (38230.0)
-
文字列のクラスです。 ヌル文字を含む任意のバイト列を扱うことができます。 文字列の長さにはメモリ容量以外の制限はありません。
...ープシーケンスがほぼ無効)
"string\n" # ダブルクオート文字列 (エスケープシーケンスがすべて有効)
%q(str\\ing) # 「%q」文字列 (エスケープシーケンスがほぼ無効、デリミタが変えられる)
%Q(string\n) # 「%Q」文字列 (エスケープ......能
<<-End
この行はヒアドキュメント (終端記号をインデントできる)
End
//}
===[a:mutable] 破壊的な変更
Ruby の String クラスは mutable です。
つまり、オブジェクト自体を破壊的に変更できます。
「破壊的な変更」とは、ある......のすべての文字を破壊的に大文字へ変更する
String#upcase! メソッドの使用例を以下に示します。
//emlist[例:String#upcase!][ruby]{
a = "string"
b = a
a.upcase!
p a # => "STRING"
p b # => "STRING"
//}
この例では、a に対してメソッドを呼んだに......ブルクオートとの併用も可能
<<~End
この行のインデントは無視される
End
//}
===[a:mutable] 破壊的な変更
Ruby の String クラスは mutable です。
つまり、オブジェクト自体を破壊的に変更できます。
「破壊的な変更」とは、ある... -
String
# partition(sep) -> [String , String , String] (27435.0) -
セパレータ sep が最初に登場する部分で self を 3 つに分割し、 [最初のセパレータより前の部分, セパレータ, それ以降の部分] の 3 要素の配列を返します。
...セパレータ sep が最初に登場する部分で self を 3 つに分割し、
[最初のセパレータより前の部分, セパレータ, それ以降の部分]
の 3 要素の配列を返します。
self がセパレータを含まないときは、
返り値の第 2 要素と第 3 要......@param sep セパレータを表す文字列か正規表現を指定します。
//emlist[例][ruby]{
p "axaxa".partition("x") # => ["a", "x", "axa"]
p "aaaaa".partition("x") # => ["aaaaa", "", ""]
p "aaaaa".partition("") # => ["", "", "aaaaa"]
//}
@see String#rpartition, String#split... -
String
# rpartition(sep) -> [String , String , String] (27429.0) -
セパレータ sep が最後に登場する部分で self を 3 つに分割し、 [最後のセパレータより前の部分, セパレータ, それ以降の部分] の 3 要素の配列を返します。
...セパレータ sep が最後に登場する部分で self を 3 つに分割し、
[最後のセパレータより前の部分, セパレータ, それ以降の部分]
の 3 要素の配列を返します。
self がセパレータを含まないときは、
返り値の第 1 要素と第 2 要......素が空文字列になります。
@param sep セパレータを表す文字列か正規表現を指定します。
//emlist[例][ruby]{
p "axaxa".rpartition("x") # => ["axa", "x", "a"]
p "aaaaa".rpartition("x") # => ["", "", "aaaaa"]
//}
@see String#partition, String#split... -
String
# delete _ prefix(prefix) -> String (27321.0) -
文字列の先頭から prefix を削除した文字列のコピーを返します。
...から prefix を削除した文字列のコピーを返します。
@param prefix 先頭から削除する文字列を指定します。
@return 文字列の先頭から prefix を削除した文字列のコピー
//emlist[][ruby]{
"hello".delete_prefix("hel") # => "lo"
"hello".delete_prefix("ll......o") # => "hello"
//}
@see String#delete_prefix!
@see String#delete_suffix
@see String#start_with?... -
String
# split(sep = $ ; , limit = 0) -> [String] (27317.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。
...第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、
結果を文字列の配列で返します。
第 1 引数 sep は以下のいずれかです。
: 正規表現
正規表現にマッチする部分で分割する。
特に、括弧に......あるいは空文字列にマッチする正規表現
文字列を 1 文字ずつに分割する。マルチバイト文字を認識する。
sep が正規表現で、かつその正規表現に括弧が含まれている場合には、
各括弧のパターンにマッチした文字列も配......なし
@param sep 文字列を分割するときのセパレータのパターン
@param limit 分割する最大個数
//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]
p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ')......1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、
結果を文字列の配列で返します。
ブロックを指定すると、配列を返す代わりに分割した文字列で
ブロックを呼び出します。
第 1 引数 sep は以下の......@param sep 文字列を分割するときのセパレータのパターン
@param limit 分割する最大個数
@return ブロックを渡した場合は self、ブロックなしの場合は配列
//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]
p "... -
String
# chomp(rs = $ / ) -> String (27299.0) -
self の末尾から rs で指定する改行コードを取り除いた文字列を生成して返します。 ただし、rs が "\n" ($/ のデフォルト値) のときは、 実行環境によらず "\r", "\r\n", "\n" のすべてを改行コードとみなして取り除きます。
...by]{
p "foo\n".chomp # => "foo"
p "foo\n".chomp("\n") # => "foo"
p "foo\r\n".chomp("\r\n") # => "foo"
$/ = "\n" # デフォルト値と同じ
p "foo\r".chomp # => "foo"
p "foo\r\n".chomp # => "foo"
p "foo\n".chomp # => "foo"
p "foo\n\r".chomp # => "foo\n"
p "string\n".......chomp(nil) # => "string\n"
p "foo\r\n\n".chomp("") # => "foo"
p "foo\n\r\n".chomp("") # => "foo"
p "foo\n\r\r".chomp("") # => "foo\n\r\r"
//}
@see String#chomp!
@see String#chop.......chomp(nil) # => "string\n"
p "foo\r\n\n".chomp("") # => "foo"
p "foo\n\r\n".chomp("") # => "foo"
p "foo\n\r\r".chomp("") # => "foo\n\r\r"
//}
@see String#chomp!
@see String#chop
@see String#delete_suffix... -
String
# unpack(template) -> Array (27288.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...Array#pack で生成された文字列を
テンプレート文字列 template にしたがってアンパックし、
それらの要素を含む配列を返します。
@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるもの......は、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます。「長さ」の代わりに`*'とすることで「残り全て」
を表すこともできます。
長さ......ort
i,i!: signed int
I,I!: unsigned int
l!: signed long
L!: unsigned long
q!: signed long long
Q!: unsigned long long
j,j!: intptr_t
J,J!: uintptr_t
//}
: エンディアン依存、整数サイズ非依存 (C99 の stdint.h にある厳密な幅を持つ整数型に適切)
//emlist... -
String
# chop -> String (27281.0) -
文字列の最後の文字を取り除いた新しい文字列を生成して返します。 ただし、文字列の終端が "\r\n" であればその 2 文字を取り除きます。
...ばその 2 文字を取り除きます。
//emlist[例][ruby]{
p "string\n".chop # => "string"
p "string\r\n".chop # => "string"
p "string".chop # => "strin"
p "strin".chop # => "stri"
p "".chop # => ""
//}
@see String#chomp
@see String#chop!
@see String#delete_suffix... -
String
# unpack(template) -> Array (27276.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...Array#pack で生成された文字列を
テンプレート文字列 template にしたがってアンパックし、
それらの要素を含む配列を返します。
@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるもの......は、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます。「長さ」の代わりに`*'とすることで「残り全て」
を表すこともできます。
長さの意味はテ......ort
i,i!: signed int
I,I!: unsigned int
l!: signed long
L!: unsigned long
q!: signed long long
Q!: unsigned long long
j,j!: intptr_t
J,J!: uintptr_t
//}
: エンディアン依存、整数サイズ非依存 (C99 の stdint.h にある厳密な幅を持つ整数型に適切)
//emlist... -
String
# chop -> String (27275.0) -
文字列の最後の文字を取り除いた新しい文字列を生成して返します。 ただし、文字列の終端が "\r\n" であればその 2 文字を取り除きます。
...終端が "\r\n" であればその 2 文字を取り除きます。
//emlist[例][ruby]{
p "string\n".chop # => "string"
p "string\r\n".chop # => "string"
p "string".chop # => "strin"
p "strin".chop # => "stri"
p "".chop # => ""
//}
@see String#chomp
@see String#chop!... -
String
# upcase(*options) -> String (27263.0) -
全ての小文字を対応する大文字に置き換えた文字列を返します。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。
...のエンコーディングに依存します。
@param options オプションの詳細は String#downcase を参照してください。
//emlist[例][ruby]{
p "stRIng? STring.".upcase # => "STRING? STRING."
//}
@see String#upcase!, String#downcase,
String#swapcase, String#capitalize... -
String
# strip -> String (27257.0) -
文字列先頭と末尾の空白文字を全て取り除いた文字列を生成して返します。 空白文字の定義は " \t\r\n\f\v\0" です。
...v\0" です。
//emlist[例][ruby]{
p " abc \r\n".strip #=> "abc"
p "abc\n".strip #=> "abc"
p " abc".strip #=> "abc"
p "abc".strip #=> "abc"
p " \0 abc \0".strip #=> "abc"
str = "\tabc\n"
p str.strip #=> "abc"
p str #=> "\tabc\......n" (元の文字列は変化しない)
//}
@see String#lstrip, String#rstrip...