るりまサーチ

最速Rubyリファレンスマニュアル検索!
1553件ヒット [1401-1500件を表示] (0.047秒)

別のキーワード

  1. time rfc2822
  2. time iso8601
  3. time httpdate
  4. time parse
  5. time strptime

クラス

モジュール

キーワード

検索結果

<< < ... 13 14 15 16 > >>

Random#rand(range) -> Integer | Float (38.0)

一様な擬似乱数を発生させます。

...端を含む場合は1、含まない場合は0です)。
range.end - range.begin が実数を返す場合も同様です。
このため range が Time の場合などにもうまく動作します。

引数が実数でも範囲でもない場合は Object#to_int で変換した値が指定され...
...(4.2 は除く)
prng.rand(0...4.2) # => 3.6148130397862865
# 2012年のすべての(秒単位)時刻から一つ選ばれる
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-...
...12年のすべての時刻から一つ選ばれる
# Time#- は秒数を float で返すため。
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返すため。
# Date#- も R...

GC::Profiler.result -> String (26.0)

GC のプロファイル情報をフォーマットし、文字列として返します。

...r.enable; a = Array.new(100000){ 'aa' }; puts GC::Profiler.result"
GC 5 invokes.
Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC Time(ms)
1 0.012 165600 212940 10647...
...の起動回数
: Invoke Time
Ruby が起動してから GC が起動するまでに経過した時間
: Use Size
ヒープ内での使用サイズ
: Total Size
ヒープ全体のサイズ
: Total Object
ヒープ内に存在するオブジェクトの個数
: GC Time
GC の処理時間

@...

UnboundMethod#source_location -> [String, Integer] | nil (26.0)

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

...合は nil を返します。

//emlist[例][ruby]{
require 'time'

Time
.instance_method(:zone).source_location # => nil
Time
.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/ruby/2.4.0/time.rb", 654]
//}

@see Proc#source_location, Method#source_locati...

Data.define(*args) -> Class (20.0)

Data クラスに新しいサブクラスを作って、それを返します。

..."Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023...

Data.define(*args) {|subclass| block } -> Class (20.0)

Data クラスに新しいサブクラスを作って、それを返します。

..."Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023...

絞り込み条件を変える

GC::Profiler.report(out = $stdout) -> nil (14.0)

GC::Profiler.result の結果を out に出力します。

...t[例][ruby]{
GC::Profiler.enable
GC.start
GC::Profiler.report

# => GC 4 invokes.
# Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC Time(ms)
# 1 0.019 303720 1269840 31746...

Kernel.#format(format, *arg) -> String (14.0)

format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。

...ます。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime

=== sprintf フォーマット

Ruby の sprintf フォーマットは基本的に C 言語の sprintf(3)
のものと同じです。...
...況によってフォーマットを変えたいが引数の順序を変えたくない場合に使
用します。
//emlist[][ruby]{
case ENV['LC_TIME']
when /^ja_JP/
fmt = "%1$d年%2$d月%3$d日"
else
fmt = "%2$02d/%03$2d/%1$02d"
end

p sprintf(fmt, 1, 4, 22) #=> "04/22/01"
//}
"*" の後に...

Kernel.#sprintf(format, *arg) -> String (14.0)

format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。

...ます。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime

=== sprintf フォーマット

Ruby の sprintf フォーマットは基本的に C 言語の sprintf(3)
のものと同じです。...
...況によってフォーマットを変えたいが引数の順序を変えたくない場合に使
用します。
//emlist[][ruby]{
case ENV['LC_TIME']
when /^ja_JP/
fmt = "%1$d年%2$d月%3$d日"
else
fmt = "%2$02d/%03$2d/%1$02d"
end

p sprintf(fmt, 1, 4, 22) #=> "04/22/01"
//}
"*" の後に...

ArgumentError (8.0)

引数の数があっていないときや、数は合っていて、期待される振る舞いを持ってはいるが、期待される値ではないときに発生します。

...、数は合っていて、期待される振る舞いを持ってはいるが、期待される値ではないときに発生します。

例:

Time
.at # => wrong number of arguments (0 for 1) (ArgumentError)
Array.new(-1) # => negative array size (ArgumentError)

など

@see TypeError...
...、数は合っていて、期待される振る舞いを持ってはいるが、期待される値ではないときに発生します。

例:

Time
.at # => wrong number of arguments (given 0, expected 1..2) (ArgumentError)
Array.new(-1) # => negative array size (ArgumentError)

など...

Kernel.#Float(arg) -> Float (8.0)

引数を浮動小数点数(Float)に変換した結果を返します。

...に発生します。

//emlist[例][ruby]{
p Float(4) #=> 4.0
p Float(4_000) #=> 4000.0
p Float(9.88) #=> 9.88

p Float(Time.gm(1986)) #=> 504921600.0
p Float(Object.new) # can't convert Object into Float (TypeError)
p Float(nil) # can't convert nil into Float (...

絞り込み条件を変える

Kernel.#Float(arg, exception: true) -> Float | nil (8.0)

引数を浮動小数点数(Float)に変換した結果を返します。

...に発生します。

//emlist[例][ruby]{
p Float(4) #=> 4.0
p Float(4_000) #=> 4000.0
p Float(9.88) #=> 9.88

p Float(Time.gm(1986)) #=> 504921600.0
p Float(Object.new) # can't convert Object into Float (TypeError)
p Float(nil) # can't convert nil into Float (...

Object#_dump(limit) -> String (8.0)

Marshal.#dump において出力するオブジェクトがメソッド _dump を定義している場合には、そのメソッドの結果が書き出されます。

...い場合や拡張ライブラリで定義し
たクラスのインスタンスがインスタンス変数以外に情報を保持する場合に
利用します。(例えば、クラス Time は、_dump/_load を定義して
います)

@see Object#marshal_dump, Object#marshal_load, Class#_load...

Object#inspect -> String (8.0)

オブジェクトを人間が読める形式に変換した文字列を返します。

...の結果を使用して
オブジェクトを表示します。

//emlist[][ruby]{
[ 1, 2, 3..4, 'five' ].inspect # => "[1, 2, 3..4, \"five\"]"
Time
.new.inspect # => "2008-03-08 19:43:39 +0900"
//}

inspect メソッドをオーバーライドしなかった場合、クラス名...
<< < ... 13 14 15 16 > >>