るりまサーチ

最速Rubyリファレンスマニュアル検索!
1696件ヒット [101-200件を表示] (0.031秒)
トップページ > クエリ:end[x] > クエリ:test[x]

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. range end

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

クラス/メソッドの定義 (576.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...* defined

===[a:class] クラス定義

//emlist[例][ruby]{
class Foo < Super
def test
# ...
end

# ...
end

//}

文法:

class 識別子 [`<' superclass ]
式..
end


文法:

class 識別子 [`<' superclass ]
式..
[resc...
...ue [error_type,..] [=> evar] [then]
式..]..
[else
式..]
[ensure
式..]
end


クラスを定義します。クラス名はアルファベットの大文字で始まる識別子です。

rescue/ensure 節を指定し、例外処理...
.../emlist[][ruby]{
class Foo < Array
def foo
end

end


# 定義を追加(スーパークラス Array を明示的に指定しても同じ)
class Foo
def bar
end

end


# 間違ったスーパークラスを指定するとエラー
class Foo < String
end

# => superclass mismatch for class Foo (Typ...

ruby 1.6 feature (330.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...ーになっていました。
((<ruby-dev:17155>))

open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end

}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3...
...トで 2 回シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))

trap(:TERM, "EXIT")

END
{
puts "exit"
}

Thread.start { Thread.stop }
sleep

: 2002-04-17: Regexp#inspect

((<ruby-bugs-ja:PR#222>))

p %r{\/}...
...: 2002-03-08 class variable

((<ruby-talk:35122>))

class C
class << self
def test
@@cv = 5
p @@cv
end

end


test

end

=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
from -:9
ruby 1.6.7 (2002...

ruby 1.8.4 feature (294.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...ruby 1.8.4 feature/printf [bug]>))
* ((<ruby 1.8.4 feature/Hash [bug]>))
* ((<ruby 1.8.4 feature/test [bug]>))
* ((<ruby 1.8.4 feature/File.identical? [new]>))
* ((<ruby 1.8.4 feature/FileTest.identical? [new]>))
* ((<ruby 1.8.4 feature/File.split [change]>))
* ((<ruby 1.8.4 feature/File...
...strictly. [ruby-dev:27478]
#
# * test/ruby/test_symbol.rb: tests for [ruby-core:03573].

Symbolに適合する文字列を厳密にした。((<ruby-core:03573>)),((<ruby-dev:27478>))

1) alias :"foo" :"bar"

def bar; p "bar"; end
alias :"foo" :"bar"...
..."$- "
2631438

# => ruby 1.8.4 (2005-12-22) [i686-linux]
-:2: syntax error, unexpected '(', expecting $end

#Tue Nov 1 14:20:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
#
# * eval.c (rb_call_super): should call method_missing if super is
#...

NEWS for Ruby 2.7.0 (252.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...p b #=> 1
p c #=> [2, 3]
end

//}

//emlist[][ruby]{
case {a: 0, b: 1}
in {a: 0, x: 1}
:unreachable
in {a: 0, b: var}
p var #=> 1
end

//}

//emlist[][ruby]{
case -1
in 0 then :unreachable
in 1 then :unreachable
end
#=> NoMatchingPatternError
//}

//emlist{
json = <<END
{
"name": "Alice",
"a...
...ge": 30,
"children": [{ "name": "Bob", "age": 2 }]
}
END


JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: name, age: age}]}

p name #=> "Bob"
p age #=> 2

JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charlie", age: age}]}
#=> NoMatchin...
...16256

//emlist[test.rb][ruby]{
require "optparse"
OptionParser.new do |opts|
opts.on("-f", "--foo", "foo") {|v| }
opts.on("-b", "--bar", "bar") {|v| }
opts.on("-c", "--baz", "baz") {|v| }
end
.parse!
//}

//emlist{
$ ruby test.rb --baa
Traceback (most recent call last):
test
.rb:7:in `<main>':...

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (168.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end


def test2(start, length)
test
1(start, length)
end


def test3(start, length)
test
2(start, length)
end


caller_locations # => []
test
3(1, nil)
#...
.../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test
3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9...
..., 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test
3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

絞り込み条件を変える

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (168.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end


def test2(start, length)
test
1(start, length)
end


def test3(start, length)
test
2(start, length)
end


caller_locations # => []
test
3(1, nil)
#...
.../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test
3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9...
..., 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test
3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Rake::FileList#import(array) -> self (132.0)

与えられた配列を自身にインポートします。

...

IO.write("test1.rb", "test")
IO.write("test2.rb", "test")

task default: :test_rake_app
task :test_rake_app do
file_list = FileList.new("test1.rb", "test2.rb", "test3.rb")
file_list.import(["test4.rb", "test5.rb"]) # => ["test4.rb", "test5.rb", "test1.rb", "test2.rb", "test3.rb"]
file_lis...
...t # => ["test4.rb", "test5.rb", "test1.rb", "test2.rb", "test3.rb"]
end

//}...

演算子式 (120.0)

演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond

...出しに変換されます。

//emlist[例][ruby]{
class C
def initialize
@ary = [0,1,2,3,4,5,6,7]
end

def [](i)
@ary[i * 2]
end

def []=( i, v )
@ary[i * 2] = v
end

end

c = C.new
p c[3] # c.[]( 3 ) に変換され、その結果は 6
p c[3] = 1 # c.[]=(3,1) に変換...
...C
def foo
@foo
end

def foo=( v )
@foo = v
end

end

c = C.new
c.foo = 5 # c.foo=( 5 ) のように変換される
p c.foo # => 5
//}

属性は Module#attr を使って同じように定義できます。

//emlist[例][ruby]{
class C
attr :foo, true
end

c = C.new
c.foo = 5...
...2)...(n==3)
p n
end

}
#=> 2
# 3

# 「..」と「...」の違いを示すためだけの例

5.times{|n|
if (n==2)..(n==2)
p n
end

}
#=> 2

5.times{|n|
if (n==2)...(n==2)
p n
end

}
#=> 2
# 3
# 4
//}

===[a:and] and

//emlist[例][ruby]{
test
&& set
test
and set
//}

...

Rake::FileList#gsub!(pattern, replace) -> self (96.0)

自身に含まれるファイルリストのそれぞれのエントリに対して String#gsub を実行します。 自身を破壊的に変更します。

...rite("test1.rb", "test")
IO.write("test2.rb", "test")

task default: :test_rake_app
task :test_rake_app do
file_list = FileList.new("test1.rb", "test2.rb", "test3.rb")
file_list.gsub!(/\.rb/, ".erb") # => ["test1.erb", "test2.erb", "test3.erb"]
file_list # => ["test1.erb"...
..., "test2.erb", "test3.erb"]
end

//}...

ruby 1.8.3 feature (96.0)

ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))

...た。

$ cat mthd_taint.rb
th = Thread.new{
$SAFE = 3
class Hoge
def foo
puts "safe level: #{$SAFE}"
end

end

}
th.join
p $SAFE
Hoge.new.foo

$ ruby-1.8.2 mthd_taint.rb
0
"safe level: 0"

$ ruby-1.8.3 mthd_ta...
...るバグを修正しました。

$ cat r.rb
p /[\c\\]/ =~ "\c\\"
p /\c\\/ =~ "\c\\"

$ ruby-1.8.2 r.rb
r.rb:1: premature end of regular expression: /[\c\\]/
r.rb:2: invalid regular expression; '\' can't be last character: /\c\\/

$ ruby-1.8.3 r.rb
0
0

=...
...cat test_dlg.rb
foo = Object.new
foo2 = SimpleDelegator.new(foo)
def foo.bar
puts "bar"
end

foo2.bar

$ ruby-1.8.2 -r delegate test_dlg.rb
test
_dlg.rb:6: undefined method `bar' for #<Object:0x4021b0a0> (NoMethodError)

$ ruby-1.8.3 -r delegate test_dl...

絞り込み条件を変える

<< < 1 2 3 4 ... > >>