種類
- インスタンスメソッド (42)
- 特異メソッド (24)
- 文書 (22)
- モジュール関数 (19)
- 定数 (11)
クラス
-
Psych
:: Handler (11) -
Psych
:: Nodes :: Scalar (22) - Regexp (11)
-
RubyVM
:: InstructionSequence (11) - String (20)
- Struct (2)
モジュール
- Kernel (19)
検索結果
先頭5件
- Psych
:: Nodes :: Scalar :: LITERAL -> Integer - Psych
:: Handler # scalar(value , anchor , tag , plain , quoted , style) -> () - RubyVM
:: InstructionSequence . compile _ option -> Hash - Kernel
. # lambda { . . . } -> Proc - Psych
:: Nodes :: Scalar . new(value , anchor=nil , tag=nil , plain=true , quoted=false , style=ANY) -> Psych :: Nodes:Scalar
-
Psych
:: Nodes :: Scalar :: LITERAL -> Integer (24317.0) -
literal style を表します。
...literal style を表します。
@see Psych::Nodes::Scalar.new,
Psych::Nodes::Scalar#style,
Psych::Handler#scalar... -
Psych
:: Handler # scalar(value , anchor , tag , plain , quoted , style) -> () (6306.0) -
スカラー値を見付けたときに呼び出されます。
...を見付けたときに呼び出されます。
value にはスカラー値の文字列が渡されます。
anchor にはスカラー値に関連付けられた anchor の名前が文字列で渡されます。
anchor がない場合には nil が渡されます。
tag にはスカラー値に......nil が渡されます。
plain は plain style であるかどうか、quoted は quoted style であるかどうか
が渡されます。style には node の style が整数値で渡されます。
style は次の値のいずれかです。
* Psych::Nodes::Scalar::PLAIN
* Psych::Nodes::Scala......r::SINGLE_QUOTED
* Psych::Nodes::Scalar::DOUBLE_QUOTED
* Psych::Nodes::Scalar::LITERAL
* Psych::Nodes::Scalar::FOLDED
必要に応じてこのメソッドを override してください。
@param value スカラー値
@param anchor 関連付けられた anchor の名前
@param tag タグ名... -
RubyVM
:: InstructionSequence . compile _ option -> Hash (6212.0) -
命令シーケンスのコンパイル時のデフォルトの最適化オプションを Hash で返 します。
...emlist[例][ruby]{
require "pp"
pp RubyVM::InstructionSequence.compile_option
# => {:inline_const_cache=>true,
# :peephole_optimization=>true,
# :tailcall_optimization=>false,
# :specialized_instruction=>true,
# :operands_unification=>true,
# :instructions_unification=>false,
# :stack_caching=>fals......e,
# :trace_instruction=>true,
# :frozen_string_literal=>false,
# :debug_frozen_string_literal=>false,
# :coverage_enabled=>true,
# :debug_level=>0}
//}
@see RubyVM::InstructionSequence.compile_option=... -
Kernel
. # lambda { . . . } -> Proc (6206.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...また、lambda に & 引数を渡すのは推奨されません。& 引数ではなくてブロック記法で記述する必要があります。
& 引数を渡した lambda は Warning[:deprecated] = true のときに警告メッセージ
「warning: lambda without a literal block is deprecat......the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
lambda(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.new
===[a:should_use_next] 手......は yield、それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}......e the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
proc(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.new
===[a:should_use_next] 手... -
Psych
:: Nodes :: Scalar . new(value , anchor=nil , tag=nil , plain=true , quoted=false , style=ANY) -> Psych :: Nodes:Scalar (3206.0) -
Scalar オブジェクトを生成します。
...Scalar オブジェクトを生成します。
value は scalar の値を文字列で指定します。
anchor には scalar に付加されている anchor を文字列で指定します。
anchor を付けない場合には nil を指定します。
tag には scalar に付加されている t......il を指定します。
plain は plain style であるかどうか、quoted は quoted style であるかどうか
を指定します。style には node の style を整数値で渡します。
style は次の値のいずれかです。
* Psych::Nodes::Scalar::ANY
* Psych::Nodes::Scalar::PLA......IN
* Psych::Nodes::Scalar::SINGLE_QUOTED
* Psych::Nodes::Scalar::DOUBLE_QUOTED
* Psych::Nodes::Scalar::LITERAL
* Psych::Nodes::Scalar::FOLDED
@param value スカラー値
@param anchor 関連付けられた anchor の名前
@param tag タグ名
@param plain plain style であるかどうか... -
Kernel
. # `(command) -> String (3106.0) -
command を外部コマンドとして実行し、その標準出力を文字列として 返します。このメソッドは `command` の形式で呼ばれます。
...を得る必要がなく、単にコマンドを実行したいだけなら
Kernel.#system を使います。特に端末を制御するコマンドでは
`command` は失敗するかもしれません。
d:spec/literal#command も参照。
@param command コマンドとして実行する引数で......Errno::EXXX コマンドを実行できないときや失敗した場合に発生します。
//emlist[例][ruby]{
puts `ruby -v` #=> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
puts $?.inspect #=> #<Process::Status: pid=3580,exited(0)>
//}
@see Kernel.#system,Kernel.#exec,Kernel.#spawn... -
Kernel
. # proc { . . . } -> Proc (3106.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...また、lambda に & 引数を渡すのは推奨されません。& 引数ではなくてブロック記法で記述する必要があります。
& 引数を渡した lambda は Warning[:deprecated] = true のときに警告メッセージ
「warning: lambda without a literal block is deprecat......the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
lambda(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.new
===[a:should_use_next] 手......は yield、それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。
//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end
p foo().call #=> 1
//}......e the proc without lambda instead」
を出力します。
@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo &block
proc(&block)
end
it = foo{p 12}
it.call #=> 12
//}
@see Proc,Proc.new
===[a:should_use_next] 手... -
正規表現 (516.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...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]{
/京都|大阪|神戸/
//}
という正規表現においては、「京都」「大阪」「神戸」がリテラル......ことが
できます。
//emlist[][ruby]{
place = "東京都"
/#{place}/.match("Go to 東京都") # => #<MatchData "東京都">
//}
埋め込んだ文字列にメタ文字が含まれているならば、それは
メタ文字として認識されます。
//emlist[][ruby]{
number = "(\\d+)"
op... -
Struct
. new(*args , keyword _ init: nil) -> Class (236.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
...ンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス......めだと考えた方が良いでしょう。
したがって、メンバ名は Symbol で指定するのが無難です。
@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init true を指定すると、キーワード引......//}
//emlist[警告が出る例][ruby]{
Point = Struct.new(:x, :y)
Point.new(x: 1, y: 2) # => #<struct Point x={:x=>1, :y=>2}, y=nil>
# warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new(... -
Struct
. new(*args , keyword _ init: nil) {|subclass| block } -> Class (236.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
...ンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス......めだと考えた方が良いでしょう。
したがって、メンバ名は Symbol で指定するのが無難です。
@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init true を指定すると、キーワード引......//}
//emlist[警告が出る例][ruby]{
Point = Struct.new(:x, :y)
Point.new(x: 1, y: 2) # => #<struct Point x={:x=>1, :y=>2}, y=nil>
# warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new(... -
Regexp
# ~ -> Integer | nil (206.0) -
変数 $_ の値との間でのマッチをとります。
...//emlist[][ruby]{
self =~ $_
//}
//emlist[例][ruby]{
$_ = "hogehoge"
if /foo/
puts "match"
else
puts "no match"
end
# => no match
# ただし、警告がでる。warning: regex literal in condition
reg = Regexp.compile("foo")
if ~ reg
puts "match"
else
puts "no match"
end
# => no m......atch
if reg
puts "match"
else
puts "no match"
end
# => match
# reg は nil でも false でも無いので常にtrue
//}... -
String
# +@ -> String | self (206.0) -
self が freeze されている文字列の場合、元の文字列の複製を返します。 freeze されていない場合は self を返します。
...self が freeze されている文字列の場合、元の文字列の複製を返します。
freeze されていない場合は self を返します。
//emlist[例][ruby]{
# frozen_string_literal: false
original_text = "text"
unfrozen_text = +original_text
unfrozen_text.frozen?......# => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => true
original_text = "text".freeze
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_tex......t) # => false
//}
@see String#-@... -
String
# -@ -> String | self (206.0) -
self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。
...self が freeze されている文字列の場合、self を返します。
freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。
//emlist[例][ruby]{
# frozen_string_literal: false
original_text = "text"
frozen_text = -original_t......# => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => false
original_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => tru...