るりまサーチ

最速Rubyリファレンスマニュアル検索!
1547件ヒット [1-100件を表示] (0.050秒)
トップページ > クエリ:Method[x] > クエリ:String[x]

別のキーワード

  1. irb/input-method gets
  2. irb/input-method new
  3. _builtin define_method
  4. irb/input-method encoding
  5. irb/input-method readable_atfer_eof?

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Method#inspect -> String (21246.0)

self を読みやすい文字列として返します。

...します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ...
...klass2 は、実際にそのメソッドを定義しているクラス/モジュール名、
method
は、メソッド名を表します。

arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。

//em...
...ラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>

# 以下は(形式1)の出力になる
module Baz
def baz
end
end

class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:23>
//}

@see Object#inspect...

Method#to_s -> String (21246.0)

self を読みやすい文字列として返します。

...します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ...
...klass2 は、実際にそのメソッドを定義しているクラス/モジュール名、
method
は、メソッド名を表します。

arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。

//em...
...ラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>

# 以下は(形式1)の出力になる
module Baz
def baz
end
end

class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:23>
//}

@see Object#inspect...

Method#inspect -> String (21234.0)

self を読みやすい文字列として返します。

...します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュ...
...モジュール名、
method
は、メソッド名を表します。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}

klass...
...が同じ場合は以下の形式になります。
#<Method: klass1#method> (形式2)

特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列...

Method#to_s -> String (21234.0)

self を読みやすい文字列として返します。

...します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュ...
...モジュール名、
method
は、メソッド名を表します。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}

klass...
...が同じ場合は以下の形式になります。
#<Method: klass1#method> (形式2)

特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列...

String#encode(**options) -> String (21127.0)

self を指定したエンコーディングに変換した文字列を作成して返します。引数 を2つ与えた場合、第二引数は変換元のエンコーディングを意味します。さもな くば self のエンコーディングが使われます。 無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

...す。
: :replace => string
前述の :invalid => :replace や :undef => :replace で用いられる置換文字を指定します。デフォルトは Unicode 系のエンコーディングならば U+FFFD、それ以外では "?" です。
: :fallback => Hash | Proc | Method
未定義の文字...
...に対する置換文字を設定します。このオプションに与えられるオブジェクトは Hash, Proc, Method のいずれかまたは [] メソッドを持つオブジェクトです。
キーは現在のトランスコーダのソースエンコーディングで未定義の文字...
...ようとすると Encoding::UndefinedConversionError が発生する
str = "\u00b7\u2014"
str.encode("Windows-31J", fallback: { "\u00b7" => "\xA5".force_encoding("Windows-31J"),
"\u2014" => "\x81\x5C".force_encoding("Windows-31J") })
//}

@see String#encode!...

絞り込み条件を変える

String#encode(encoding, **options) -> String (21127.0)

self を指定したエンコーディングに変換した文字列を作成して返します。引数 を2つ与えた場合、第二引数は変換元のエンコーディングを意味します。さもな くば self のエンコーディングが使われます。 無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

...す。
: :replace => string
前述の :invalid => :replace や :undef => :replace で用いられる置換文字を指定します。デフォルトは Unicode 系のエンコーディングならば U+FFFD、それ以外では "?" です。
: :fallback => Hash | Proc | Method
未定義の文字...
...に対する置換文字を設定します。このオプションに与えられるオブジェクトは Hash, Proc, Method のいずれかまたは [] メソッドを持つオブジェクトです。
キーは現在のトランスコーダのソースエンコーディングで未定義の文字...
...ようとすると Encoding::UndefinedConversionError が発生する
str = "\u00b7\u2014"
str.encode("Windows-31J", fallback: { "\u00b7" => "\xA5".force_encoding("Windows-31J"),
"\u2014" => "\x81\x5C".force_encoding("Windows-31J") })
//}

@see String#encode!...

String#encode(encoding, from_encoding, **options) -> String (21127.0)

self を指定したエンコーディングに変換した文字列を作成して返します。引数 を2つ与えた場合、第二引数は変換元のエンコーディングを意味します。さもな くば self のエンコーディングが使われます。 無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

...す。
: :replace => string
前述の :invalid => :replace や :undef => :replace で用いられる置換文字を指定します。デフォルトは Unicode 系のエンコーディングならば U+FFFD、それ以外では "?" です。
: :fallback => Hash | Proc | Method
未定義の文字...
...に対する置換文字を設定します。このオプションに与えられるオブジェクトは Hash, Proc, Method のいずれかまたは [] メソッドを持つオブジェクトです。
キーは現在のトランスコーダのソースエンコーディングで未定義の文字...
...ようとすると Encoding::UndefinedConversionError が発生する
str = "\u00b7\u2014"
str.encode("Windows-31J", fallback: { "\u00b7" => "\xA5".force_encoding("Windows-31J"),
"\u2014" => "\x81\x5C".force_encoding("Windows-31J") })
//}

@see String#encode!...

String#to_s -> String (21120.0)

self を返します。

...であるメソッド some_method があるとき、
to_s メソッドを使うと以下のように統一的に処理できます。

//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_method(5).to_s.downcase
//}...

String#to_str -> String (21120.0)

self を返します。

...であるメソッド some_method があるとき、
to_s メソッドを使うと以下のように統一的に処理できます。

//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_method(5).to_s.downcase
//}...

Method#source_location -> [String, Integer] | nil (21119.0)

ソースコードのファイル名と行番号を配列で返します。

...@see Proc#source_location

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----

require '/tmp/foo'

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.source_location # => ["/tmp/foo.rb", 2]

method
(:puts).source_location # => nil
//}...

絞り込み条件を変える

JSON::Ext::Generator::GeneratorMethods::String (21016.0)

Alias of JSON::Generator::GeneratorMethods::String

...Alias of JSON::Generator::GeneratorMethods::String...

JSON::Generator::GeneratorMethods::String (21016.0)

String に JSON で使用するインスタンスメソッドを追加するためのモジュールです。

...String に JSON で使用するインスタンスメソッドを追加するためのモジュールです。...
<< 1 2 3 ... > >>