るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

String (38324.0)

文字列のクラスです。 ヌル文字を含む任意のバイト列を扱うことができます。 文字列の長さにはメモリ容量以外の制限はありません。

...字列リテラルの例をいくつか示します。

//emlist[文字列リテラルの例][ruby]{
'str\\ing' # シングルクオート文字列 (エスケープシーケンスがほぼ無効)
"string\n" # ダブルクオート文字列 (エスケープシーケンスがすべて有効)
%q(st...
...も可能
<<-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 です。
つまり、オブジェクト自体を破壊的に変更できます。

「破壊的な変更」とは、あ...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (32456.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を...
...ode#token が利用できます。
@param error_tolerant true を指定すると、構文エラーが発生した際にエラー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
@raise SyntaxError string Ruby のコードとして正しくな...
...//emlist[][ruby]{
p
p RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
p
p RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", er...

RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (32456.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を...
...ode#token が利用できます。
@param error_tolerant true を指定すると、構文エラーが発生した際にエラー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
@raise SyntaxError string Ruby のコードとして正しくな...
...//emlist[][ruby]{
p
p RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
p
p RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", er...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (32449.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@raise SyntaxError string Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
p
p RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl...
...: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
//}...

RubyVM::AbstractSyntaxTree::Node#inspect -> String (32213.0)

self のデバッグ用の情報を含んだ文字列を返します。

...self のデバッグ用の情報を含んだ文字列を返します。

//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 1')
p
uts node.inspect
# => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:5>
//}...

絞り込み条件を変える

RubyVM::InstructionSequence#inspect -> String (32213.0)

self の情報をラベルとパスを含んだ人間に読みやすい文字列にして返します。

...んだ人間に読みやすい文字列にして返します。

//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
iseq.inspect # => "<RubyVM::InstructionSequence:<compiled>@<compiled>>"
//}

@see RubyVM::InstructionSequence#label,
Ruby
VM::InstructionSequence#path...

RubyVM::InstructionSequence#absolute_path -> String | nil (32201.0)

self が表す命令シーケンスの絶対パスを返します。

...= RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.absolute_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello
p
uts "hello, world"
end

# irb
> iseq = Ruby...
...VM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@see RubyVM::InstructionSequence#path...

RubyVM::InstructionSequence#path -> String (32201.0)

self が表す命令シーケンスの相対パスを返します。

..."<compiled>" を返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/meth...
...od.rb
def hello
p
uts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('method.rb')
> iseq.path # => "method.rb"

@see RubyVM::InstructionSequence#absolute_path...

RubyVM::OPTS -> [String] (32201.0)

RubyVM のビルドオプションの一覧を返します。

...
Ruby
VM のビルドオプションの一覧を返します。...

RubyVM::InstructionSequence.compile_option -> Hash (32124.0)

命令シーケンスのコンパイル時のデフォルトの最適化オプションを Hash で返 します。

...ンを Hash で返
します。

//emlist[例][ruby]{
require "pp"
p
p RubyVM::InstructionSequence.compile_option

# => {:inline_const_cache=>true,
# :peephole_optimization=>true,
# :tailcall_optimization=>false,
# :specialized_instruction=>true,
# :operands_unification=>true,
# :instructions_unifica...
...tion=>false,
# :stack_caching=>false,
# :trace_instruction=>true,
# :frozen_string_literal=>false,
# :debug_frozen_string_literal=>false,
# :coverage_enabled=>true,
# :debug_level=>0}
//}

@see RubyVM::InstructionSequence.compile_option=...

絞り込み条件を変える

String#unpack(template) -> Array (28462.0)

Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。

...Array#pack で生成された文字列を
テンプレート文字列 template にしたがってアンパックし、
それらの要素を含む配列を返します。

@param template pack テンプレート文字列
@return オブジェクトの配列


以下にあげるもの...
...は、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます。「長さ」の代わりに`*'とすることで「残り全て」
を表すこともできます。

長さの意味はテ...
...pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の説明 / String#unpack の説明」としています。

: a

ASCII文字列(ヌル文字を詰める/後続するヌル文字やスペースを残す)
//emlist[][ruby]{
["abc"].pack("a") # => "a"
["abc"].p...
...は、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます。「長さ」の代わりに`*'とすることで「残り全て」
を表すこともできます。

長さ...
<< 1 2 3 ... > >>