ライブラリ
- ビルトイン (1000)
- bigdecimal (12)
- csv (36)
- ipaddr (12)
-
irb
/ context (48) - matrix (24)
-
net
/ smtp (12) - openssl (12)
- optparse (12)
- ostruct (24)
- pp (24)
- rake (60)
-
rdoc
/ context (12) -
rdoc
/ markup (12) -
rubygems
/ commands / dependency _ command (12) -
rubygems
/ commands / lock _ command (12) -
rubygems
/ gem _ path _ searcher (24) -
rubygems
/ remote _ fetcher (12) -
rubygems
/ source _ index (24) -
rubygems
/ spec _ fetcher (24) -
rubygems
/ specification (444) - scanf (48)
- set (14)
-
shell
/ filter (6) - socket (24)
- strscan (12)
- uri (24)
- win32ole (12)
- zlib (12)
クラス
-
ARGF
. class (36) - Addrinfo (12)
- Array (24)
- BigDecimal (12)
- Bignum (6)
- Binding (7)
- CSV (12)
-
CSV
:: Row (12) -
CSV
:: Table (12) - Complex (12)
- Data (6)
- Dir (12)
- Encoding (24)
-
Encoding
:: Converter (12) -
Enumerator
:: ArithmeticSequence (7) -
Enumerator
:: Chain (7) - Exception (12)
- FalseClass (24)
- Fixnum (6)
- Float (24)
-
Gem
:: Commands :: DependencyCommand (12) -
Gem
:: Commands :: LockCommand (12) -
Gem
:: GemPathSearcher (24) -
Gem
:: RemoteFetcher (12) -
Gem
:: SourceIndex (24) -
Gem
:: SpecFetcher (24) -
Gem
:: Specification (444) - Hash (24)
- IPAddr (12)
-
IRB
:: Context (48) - Integer (24)
- MatchData (16)
- Matrix (12)
- Method (24)
- Module (216)
-
Net
:: SMTP (12) - Object (54)
-
OpenSSL
:: HMAC (12) - OpenStruct (24)
-
OptionParser
:: ParseError (12) - Proc (24)
-
Process
:: Status (12) -
RDoc
:: Context :: Section (12) -
RDoc
:: Markup (12) -
RDoc
:: Options (12) -
Rake
:: FileList (12) -
Rake
:: Task (12) -
Rake
:: TaskArguments (24) - Range (12)
- Rational (12)
- Regexp (12)
-
RubyVM
:: AbstractSyntaxTree :: Node (7) -
RubyVM
:: InstructionSequence (12) -
Scanf
:: FormatSpecifier (12) -
Scanf
:: FormatString (24) - Set (20)
-
Shell
:: Filter (6) -
Socket
:: Ifaddr (12) - String (36)
- StringScanner (12)
- Struct (24)
- Symbol (12)
- Thread (20)
-
Thread
:: Backtrace :: Location (12) - Time (6)
- TracePoint (12)
- TrueClass (12)
- UnboundMethod (24)
- Vector (12)
-
WIN32OLE
_ TYPE (12) -
Zlib
:: GzipFile :: Error (12)
オブジェクト
- ENV (12)
キーワード
-
$ -0 (12) -
$ -F (12) -
$ -I (12) -
$ -i (12) -
$ / (12) -
$ : (12) -
$ ; (12) -
$ LOAD _ PATH (12) - === (24)
- Encoding (12)
-
NO
_ INSPECTING _ IVARS (12) - Regexp (12)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Rubyの起動 (12)
- Ruby用語集 (12)
- SPECIAL (12)
- SPECIFIERS (6)
-
_ _ inspect _ _ (12) -
_ dump (12) - ` (12)
-
add
_ special (12) -
alias
_ method (12) - autorequire (12)
- bindir (12)
-
cache
_ dir (12) - captures (2)
-
decode
_ www _ form (12) - deconstruct (2)
-
default
_ executable (12) -
default
_ internal (12) -
deprecate
_ constant (12) - description (12)
- dir (12)
- download (12)
- email (12)
-
encode
_ www _ form (12) - executable (12)
- executables (12)
- extensions (12)
-
extra
_ rdoc _ files (12) -
file
_ name (12) - files (12)
-
full
_ gem _ path (12) -
full
_ name (12) - homepage (12)
-
inplace
_ mode (12) - inspect (642)
-
inspect
_ sockaddr (12) -
installation
_ path (12) -
installed
_ spec _ directories (12) -
last
_ spec (6) -
last
_ spec _ tried (6) -
lib
_ dirs _ for (12) -
lib
_ files (12) -
loaded
_ from (12) -
mark
_ version (12) -
matched
_ string (6) -
matching
_ files (12) - name (24)
- normalize (12)
-
normalize
_ yaml _ input (12) -
original
_ name (12) -
original
_ platform (12) - pathmap (24)
- platform (12)
-
pretty
_ inspect (12) -
pretty
_ print _ inspect (12) -
print
_ dependencies (12) - private (48)
- protected (48)
- public (48)
-
re
_ string (6) -
require
_ path (12) -
require
_ paths (12) - rss (12)
-
ruby 1
. 8 . 4 feature (12) -
rubygems
_ version (12) - scanf (12)
-
signing
_ key (12) -
source
_ location (7) -
spec
_ count (6) -
spec
_ dirs (12) -
spec
_ path (12) - summary (12)
- tainted? (6)
-
test
_ file (12) -
test
_ files (12) -
test
_ suite _ file (12) -
to
_ ruby (12) -
to
_ s (193) -
trace
_ var (36) - trap (24)
- yaml (12)
- クラス/メソッドの定義 (12)
- パターンマッチ (12)
- リテラル (12)
- 多言語化 (12)
- 正規表現 (12)
検索結果
-
String (38132.0)
-
文字列のクラスです。 ヌル文字を含む任意のバイト列を扱うことができます。 文字列の長さにはメモリ容量以外の制限はありません。
...ープシーケンスがほぼ無効)
"string\n" # ダブルクオート文字列 (エスケープシーケンスがすべて有効)
%q(str\\ing) # 「%q」文字列 (エスケープシーケンスがほぼ無効、デリミタが変えられる)
%Q(string\n) # 「%Q」文字列 (エスケープ......能
<<-End
この行はヒアドキュメント (終端記号をインデントできる)
End
//}
===[a:mutable] 破壊的な変更
Ruby の String クラスは mutable です。
つまり、オブジェクト自体を破壊的に変更できます。
「破壊的な変更」とは、ある......詳しく知りたい場合は、spec/m17n を参照してください。
==== 文字列同士の比較・結合
文字列同士の比較・結合などでは両者のエンコーディングを意識する必要があります。
例えば String#== や String#eql? は両者のエンコーディ......ブルクオートとの併用も可能
<<~End
この行のインデントは無視される
End
//}
===[a:mutable] 破壊的な変更
Ruby の String クラスは mutable です。
つまり、オブジェクト自体を破壊的に変更できます。
「破壊的な変更」とは、ある... -
String
# inspect -> String (27225.0) -
文字列オブジェクトの内容を、出力したときに人間が読みやすいような適当な形式に変換します。 変換された文字列は印字可能な文字のみによって構成されます
...ために用意されています。
永続化などの目的で文字列をダンプしたいときは、
String#dump を使うべきです。
//emlist[例][ruby]{
# p ではないことに注意
puts "string".inspect # => "string"
puts "\t\r\n".inspect # => "\t\r\n"
//}
@see String#dump... -
リテラル (23220.0)
-
リテラル * num * string * backslash * exp * char * command * here * regexp * array * hash * range * symbol * percent
...リテラル
* num
* string
* backslash
* exp
* char
* command
* here
* regexp
* array
* hash
* range
* symbol
* percent
数字の1や文字列"hello world"のようにRubyのプログラムの中に直接
記述できる値の事をリテラルといいます。
===[a:n......f # => 0xffffffff
//}
===[a:string] 文字列リテラル
//emlist[例][ruby]{
"this is a string expression\n"
'this is a string expression\n'
%q!I said, "You said, 'She said it.'"!
%!I said, "You said, 'She said it.'"!
%Q('This is it.'\n)
"this is multi line
string"
//}
文字列はダブル......name is #{myname}/o
%r|Ruby|
//}
/で囲まれた文字列は正規表現です。正規表現として解釈される
メタ文字についてはspec/regexpを参照してください。
終りの/の直後の文字は正規表現に対するオプションになります。
オプションの......とができます。
//emlist[][ruby]{
expected_result = <<~SQUIGGLY_HEREDOC
This would contain specially formatted text.
That might span many lines
SQUIGGLY_HEREDOC
# => "This would contain specially formatted text.\n" + "\n" + "That might span many lines\n"
//}
最もインデントが少... -
クラス/メソッドの定義 (23060.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...ァベットの大文字で始まる識別子です。
rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。
クラス定義は、識別子で指定した定数へのクラスの代入になります
(Ruby では、クラスもオ......ray を明示的に指定しても同じ)
class Foo
def bar
end
end
# 間違ったスーパークラスを指定するとエラー
class Foo < String
end
# => superclass mismatch for class Foo (TypeError)
//}
クラス定義式の中は self がそのクラスであることと、
limitのデ......たオブジェクトには引き継がれません.
rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。
特異クラス定義式は、最後に評価した式の結果を返します。最後に評価した式
が値を返さ... -
正規表現 (23052.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...現
* metachar
* expansion
* char
* anychar
* string
* str
* quantifier
* capture
* grouping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references
正規表現(regular expression)......以外の
その文字列そのものにマッチするような文字列があります。
前者をメタ文字列(meta string)、後者をリテラル(文字列)(literal string)と呼びます。
//emlist[][ruby]{
/京都|大阪|神戸/
//}
という正規表現においては、「京都」「......Ruby の文法で特別な意味を持つ文字を埋め込む
ためなどに用いられます。
文字列リテラルの記法とほぼ同様(d:spec/literal#backslash)で、
以下の記法が利用可能です。
\t 水平タブ horizontal tab (0x09)
\v 垂... -
多言語化 (23048.0)
-
多言語化 Ruby は US-ASCII はもちろん、US-ASCII 以外の文字エンコーディングもサポートしています。 文字列の内部表現のエンコーディングは固定されておらず、 プログラマは目的に応じて使用するエンコーディングを選ぶことができます。
...できます。
同じプロセスの中で異なるエンコーディングの文字列が同時に存在することができます。
全ての String や Regexp などのオブジェクトは自身のエンコーディング情報を保持しています。
これにより各オブジェクト......ソッドを用います。
String#encode メソッドは文字列のエンコーディングを変換した新しい文字列を生成して返します。
Ruby 1.9 ではこれを用いてエンコーディングを変換するのが標準的なやり方です。
String#force_encoding メソッ......列をエンコーディングの変換なしで結合することができます。
また、通常 Ruby の文字列比較メソッドである String#== は、
2 つの文字列のエンコーディングが異なっていると、バイト列としては一致していても false を返しま... -
Rubyの起動 (23012.0)
-
Rubyの起動 * cmd_option * shebang
...default: enabled)
* did_you_mean did_you_mean (default: enabled)
* rubyopt RUBYOPT 環境変数 (default: enabled)
* frozen-string-literal 全ての文字列リテラルをfreeze (default: disabled)
//}
: --disable
指定した feature(--enable を参照)を無効にしま......します。それから, -n
フラグまたは-pフラグが指定されていると
gets
で読み込まれた各行の最後に対して
String#chop!を行います。
: -n
このフラグがセットされるとプログラム全体が
sed -nやawk
のように
//emlist{
whil......します。それから, -n
フラグまたは-pフラグが指定されていると
gets
で読み込まれた各行の最後に対して
String#chomp!を行います。
: -n
このフラグがセットされるとプログラム全体が
sed -nやawk
のように
//emlist{
whi......default: enabled)
* did_you_mean did_you_mean (default: enabled)
* rubyopt RUBYOPT 環境変数 (default: enabled)
* frozen-string-literal 全ての文字列リテラルをfreeze (default: disabled)
* jit JIT (default: disabled)
//}
: --disable
指定した......default: enabled)
* did_you_mean did_you_mean (default: enabled)
* rubyopt RUBYOPT 環境変数 (default: enabled)
* frozen-string-literal 全ての文字列リテラルをfreeze (default: disabled)
* jit JIT (default: disabled)
* mjit MJIT (defa... -
パターンマッチ (23012.0)
-
パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples
...が、オブジェクトの一部の要素がマッチしていることを検査できます。
//emlist{
case ["a", 1, "b", "c", 2]
in [*, String, String, *]
"matched"
else
"not matched"
end
//}
===[a:variable_binding] 変数の束縛
深い構造検査の他のパターンマッチの重......d
def deconstruct
puts "deconstruct called"
[@x, @y]
end
def deconstruct_keys(keys)
puts "deconstruct_keys called with #{keys.inspect}"
{x: @x, y: @y}
end
end
case Point.new(1, -2)
in px, Integer # パターンと変数への束縛も動きます
"matched: #{px}"
else... -
String
# pathmap(spec = nil) { . . . } -> String (21202.0) -
与えられた書式指定文字列に応じてパス(自身)を変換します。
与えられた書式指定文字列に応じてパス(自身)を変換します。
与えられた書式指定文字列は変換の詳細を制御します。
指定できる書式指定文字列は以下の通りです。
: %p
完全なパスを表します。
: %f
拡張子付きのファイル名を表します。ディレクトリ名は含まれません。
: %n
拡張子なしのファイル名を表します。
: %d
パスに含まれるディレクトリのリストを表します。
: %x
パスに含まれるファイルの拡張子を表します。拡張子が無い場合は空文字列を表します。
: %X
拡張子以外すべてを表します。
: %s
定義されていれば、代替のファイルセパレータを表します。...