るりまサーチ

最速Rubyリファレンスマニュアル検索!
2696件ヒット [2301-2400件を表示] (0.416秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

モジュール

キーワード

検索結果

<< < ... 22 23 24 25 26 ... > >>

IO.write(path, string, **opts) -> Integer (108.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...path で指定されるファイルを開き、string を書き込み、
閉じます。

Kernel
.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。

offset を指定するとその位置までシー...
...ディングなどを指定することができます。
詳しくは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数

//emlist[例][ruby...

IO.write(path, string, offset=nil, **opts) -> Integer (108.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...path で指定されるファイルを開き、string を書き込み、
閉じます。

Kernel
.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。

offset を指定するとその位置までシー...
...ディングなどを指定することができます。
詳しくは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数

//emlist[例][ruby...

String#to_f -> Float (92.0)

文字列を 10 進数表現と解釈して、浮動小数点数 Float に変換します。

...emlist[][ruby]{
p
"-10".to_f # => -10.0
p
"10e2".to_f # => 1000.0
p
"1e-2".to_f # => 0.01
p
".1".to_f # => 0.1

p
"1_0_0".to_f # => 100.0 # 数値リテラルと同じように区切りに _ を使える
p
" \n10".to_f # => 10.0 # 先頭の空白・改行は無視される
p
"7xa.5".to_f #...
...0.0 を返します。
変換対象が空文字列のケースでも、0.0 を返します。

//emlist[][ruby]{
p
"".to_f # => 0.0
p
"nan".to_f # => 0.0
p
"INF".to_f # => 0.0
p
"-Inf".to_f # => 0.0
//}

変換後の Float が有限の値を取れないときは、Float::INFINITY を用い...
...W2

p
("10" * 1000).to_f # => Infinity
# warning: Float 10101010101010101010... out of range
//}

なお、このメソッドとは逆に、数値を文字列に変換するには
Kernel
.#sprintf, String#%, Integer#to_s
を使用します。

@see String#hex, String#oct, String#to_i,
Kernel
.#...

String#oct -> Integer (86.0)

文字列を 8 進文字列であると解釈して、整数に変換します。

...//emlist[例][ruby]{
p
"10".oct # => 8
p
"010".oct # => 8
p
"8".oct # => 0
//}

oct は文字列の接頭辞 ("0", "0b", "0B", "0x", "0X") に応じて
8 進以外の変換も行います。

//emlist[例][ruby]{
p
"0b10".oct # => 2
p
"10".oct # => 8
p
"010".oct # => 8
p
"0x10".oct # => 16...
...

//emlist[例][ruby]{
p
"-010".oct # => -8
p
"-0x10".oct # => -16
p
"-0b10".oct # => -2

p
"1_0_1x".oct # => 65
//}

@see String#hex, String#to_i, String#to_f,
Kernel
.#Integer, Kernel.#Float

逆に、数値を文字列に変換するにはKernel.#sprintf,
String#%, Integer#to_s...

String#hex -> Integer (68.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...//emlist[例][ruby]{
p
"10".hex # => 16
p
"ff".hex # => 255
p
"0x10".hex # => 16
p
"-0x10".hex # => -16

p
"xyz".hex # => 0
p
"10z".hex # => 16
p
"1_0".hex # => 16

p
"".hex # => 0
//}

@see String#oct, String#to_i, String#to_f,
Kernel
.#Integer, Kernel.#Float

このメソ...
...ッドの逆に数値を文字列に変換するには
Kernel
.#sprintf, String#%,
Integer#to_s
などを使ってください。...

絞り込み条件を変える

Object#freeze -> self (50.0)

オブジェクトを凍結(内容の変更を禁止)します。

...数なら Kernel.#trace_var が使えます。

@return self を返します。

//emlist[][ruby]{
a1 = "foo".freeze
a1 = "bar"
p
a1 #=> "bar"

a2 = "foo".freeze
a2.replace("bar") # can't modify frozen String (RuntimeError)
//}

凍結を解除することはできませんが、Object#dup を使え...
...ます。

//emlist[][ruby]{
a = [1].freeze
p
a.frozen? #=> true

a[0] = "foo"
p
a # can't modify frozen Array (RuntimeError)

b = a.dup
p
b #=> [1]
p
b.frozen? #=> false

b[0] = "foo"
p
b #=> ["foo"]
//}

@see Object#frozen?,Object#dup,Kernel.#trace_var...
...数なら Kernel.#trace_var が使えます。

@return self を返します。

//emlist[][ruby]{
a1 = "foo".freeze
a1 = "bar"
p
a1 #=> "bar"

a2 = "foo".freeze
a2.replace("bar") # can't modify frozen String (FrozenError)
//}

凍結を解除することはできませんが、Object#dup を使え...
...ます。

//emlist[][ruby]{
a = [1].freeze
p
a.frozen? #=> true

a[0] = "foo"
p
a # can't modify frozen Array (FrozenError)

b = a.dup
p
b #=> [1]
p
b.frozen? #=> false

b[0] = "foo"
p
b #=> ["foo"]
//}

@see Object#frozen?,Object#dup,Kernel.#trace_var...

Module#autoload(const_name, feature) -> nil (48.0)

定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

...定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoload...
...しません。

@param const_name String または Symbol で指定します。
なお、const_name には、"::" 演算子を含めることはできません。
つまり、self の直下に定義された定数しか指定できません。

@param feature Kernel.#require と同様...
...tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----

class Foo
autoload :Bar, '/tmp/foo'
end
p
Foo::Bar #=> Foo::Bar
//}

以下のようにモジュールを明示的にレシーバとして呼び出すこともできます。

//emlist[例][ruby]{
# ------- /tmp/...

Object#class -> Class (44.0)

レシーバのクラスを返します。

...レシーバのクラスを返します。

//emlist[][ruby]{
p
"ruby".class #=> String
p
100.class #=> Integer
p
ARGV.class #=> Array
p
self.class #=> Object
p
Class.class #=> Class
p
Kernel.class #=> Module
//}

@see Class#superclass,Object#kind_of?,Object#instance_of?...

FileTest.#identical?(file1, file2) -> bool (38.0)

file1 と file2 が同じファイルを指している時に真を返します。 そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...y 1.8.3 以前ではKernel.#test(?-, file1, file2)を使ってください。

open("a", "w") {}
p
File.identical?("a", "a") #=> true
p
File.identical?("a", "./a") #=> true
File.link("a", "b")
p
File.identical?("a", "b") #=> true
File.symlink("a", "c")
p
File.identical?("a...
...", "c") #=> true
open("d", "w") {}
p
File.identical?("a", "d") #=> false

@param file1 ファイル名を表す文字列か IO オブジェクトを指定します。

@param file2 ファイル名を表す文字列か IO オブジェクトを指定します。

@raise IOError 指定さ...

Module#constants(inherit = true) -> [Symbol] (38.0)

そのモジュール(またはクラス)で定義されている定数名の配列を返します。

...ません。

@param inherit true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables...
...nd
class Bar
BAR = 1

# Bar は BAR を含む
p
constants # => [:BAR]
# 出力に FOO は含まれない
p
Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p
constants # => []

#...
...ネストしたクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constants には含まれる
# (クラス Baz も Bar の定数なので同様)
p
Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}...

絞り込み条件を変える

<< < ... 22 23 24 25 26 ... > >>