るりまサーチ

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

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

ライブラリ

クラス

キーワード

検索結果

Object#then -> Enumerator (24256.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#then {|x| ... } -> object (24256.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#yield_self -> Enumerator (9256.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#yield_self {|x| ... } -> object (9256.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Time.strptime(date, format, now=self.now) -> Time (9244.0)

文字列を Date._strptime を用いて Time オブジェクト に変換します。

...Date._strptime を用いて Time オブジェクト
に変換します。

require 'time'
T
ime.strptime('2001-02-03T04:05:06+09:00', '%Y-%m-%dT%H:%M:%S%z')
#=> 2001-02-03 06:05:06 +0900

ブロックを渡すと年の部分をブロックによって変換できます。
require 'time'
T
im...
...e.strptime('91/5/18 4:13:00', '%Y/%m/%d %T'){|y|
if y > 100 then y
elsif y >= 69 then y + 1900
else y + 2000
end
}
#=> 1991-05-18 04:13:00 +0900

T
ime.strptime('01/5/18 4:13:00', '%Y/%m/%d %T'){|y|
if y > 100 then y
elsif y >= 69 then y + 1900
else y + 2000...
...end
}
#=> 2001-05-18 04:13:00 +0900

詳しくは DateTime.strptime, Date.strptime を見てください。

@param date 時刻を表す文字列
@param format 書式文字列...

絞り込み条件を変える

Time.strptime(date, format, now=self.now) {|y| ... } -> Time (9244.0)

文字列を Date._strptime を用いて Time オブジェクト に変換します。

...Date._strptime を用いて Time オブジェクト
に変換します。

require 'time'
T
ime.strptime('2001-02-03T04:05:06+09:00', '%Y-%m-%dT%H:%M:%S%z')
#=> 2001-02-03 06:05:06 +0900

ブロックを渡すと年の部分をブロックによって変換できます。
require 'time'
T
im...
...e.strptime('91/5/18 4:13:00', '%Y/%m/%d %T'){|y|
if y > 100 then y
elsif y >= 69 then y + 1900
else y + 2000
end
}
#=> 1991-05-18 04:13:00 +0900

T
ime.strptime('01/5/18 4:13:00', '%Y/%m/%d %T'){|y|
if y > 100 then y
elsif y >= 69 then y + 1900
else y + 2000...
...end
}
#=> 2001-05-18 04:13:00 +0900

詳しくは DateTime.strptime, Date.strptime を見てください。

@param date 時刻を表す文字列
@param format 書式文字列...

Rake::FileList#exclude(*patterns) {|entry| ... } -> self (3213.0)

自身から取り除くべきファイル名のパターンを自身の除外リストに登録します。

...除しません。

例:
FileList['a.c', 'b.c'].exclude("a.c") # => ['b.c']
FileList['a.c', 'b.c'].exclude(/^a/) # => ['b.c']

# If "a.c" is a file, then ...
FileList['a.c', 'b.c'].exclude("a.*") # => ['b.c']

# If "a.c" is not a file, then ...
FileList['a.c', 'b.c'].exclude("a.*") # =>...

制御構造 (3096.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...構造
条件分岐:
* if
* unless
* case
繰り返し:
* while
* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END

Rubyでは(Cなどとは異なり)制御構造は式であって...
...件分岐
====[a:if] if

//emlist[例][ruby]{
if age >= 12 then
print "adult fee\n"
else
print "child fee\n"
end
gender = if foo.gender == "male" then "male" else "female" end
//}

文法:

if 式 [then]
式 ...
[elsif 式 [then]
式 ... ]
.....
...)を定義する必要があります。

//emlist[][ruby]{
class Array
def each2
i = 0
while i < self.size
yield self[i], self[i+1]
i += 2
end
end
end
//}

====[a:break] break

//emlist[例][ruby]{
i = 0
while i < 3
print i, "\n"
break
end
//}

文法:

bre...