るりまサーチ

最速Rubyリファレンスマニュアル検索!
721件ヒット [401-500件を表示] (0.091秒)
トップページ > クエリ:Kernel.#p[x] > ライブラリ:ビルトイン[x] > クエリ:Array[x] > クエリ:$-p[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. kernel $-p
  5. kernel p

クラス

キーワード

検索結果

<< < ... 3 4 5 6 7 ... > >>

String#oct -> Integer (87.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 (69.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 (51.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 (49.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 (45.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?...

絞り込み条件を変える

Module#constants(inherit = true) -> [Symbol] (39.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
//}...

Object#send(name, *args) -> object (39.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...ドを呼び出せます。
d:spec/def#limit も参照してください。

p
ublic メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッド...
...に渡す引数です。

//emlist[][ruby]{
p
-365.send(:abs) #=> 365
p
"ruby".send(:sub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p
Foo.new.send(methods[1]) # => "foo"
p
Foo.new.send(methods[2]) # => "bar"
p
Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...

Object#send(name, *args) { .... } -> object (39.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...ドを呼び出せます。
d:spec/def#limit も参照してください。

p
ublic メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッド...
...に渡す引数です。

//emlist[][ruby]{
p
-365.send(:abs) #=> 365
p
"ruby".send(:sub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p
Foo.new.send(methods[1]) # => "foo"
p
Foo.new.send(methods[2]) # => "bar"
p
Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...

Module#ancestors -> [Class, Module] (33.0)

クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。

...先順位順に配列に格納して返します。

//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p
ancestors
p
included_modules
p
superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}

@see Module#included_modules...
<< < ... 3 4 5 6 7 ... > >>