るりまサーチ

最速Rubyリファレンスマニュアル検索!
187件ヒット [1-100件を表示] (0.057秒)
トップページ > クエリ:-[x] > クエリ:dig[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method gets
  4. irb/input-method new
  5. matrix -

クラス

キーワード

検索結果

<< 1 2 > >>

Array#dig(idx, ...) -> object | nil (18267.0)

self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。

... dig メソッドで再帰的に参照して返し
ます。途中のオブジェクトが nil であった場合は nil を返します。

@param idx インデックスを整数で任意個指定します。

//emlist[例][ruby]{
a = [[1, [2, 3]]]

a.dig(0, 1, 1) # => 3
a.dig(1,...
...2, 3) # => nil
a.dig(0, 0, 0) # => TypeError: Fixnum does not have #dig method
[42, {foo: :bar}].dig(1, :foo) # => :bar
//}

@see Hash#dig, Struct#dig, OpenStruct#dig...
...2, 3) # => nil
a.dig(0, 0, 0) # => TypeError: Integer does not have #dig method
[42, {foo: :bar}].dig(1, :foo) # => :bar
//}

@see Hash#dig, Struct#dig, OpenStruct#dig...

Hash#dig(key, ...) -> object | nil (18255.0)

self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。

...クトを dig メソッドで再帰的に参照して返し
ます。途中のオブジェクトが nil であった場合は nil を返します。

@param key キーを任意個指定します。

//emlist[例][ruby]{
h = { foo: {bar: {baz: 1}}}

h.dig(:foo, :bar, :baz) # => 1
h.dig(:foo, :zo...
...t, :xyz) # => nil

g = { foo: [10, 11, 12] }
g.dig(:foo, 1) # => 11
//}

@see Array#dig, Struct#dig, OpenStruct#dig...

Struct#dig(key, ...) -> object | nil (18249.0)

self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。

...クトを dig メソッドで再帰的に参照して返し
ます。途中のオブジェクトが nil であった場合は nil を返します。

@param key キーを任意個指定します。

//emlist[例][ruby]{
klass = Struct.new(:a)
o = klass.new(klass.new({b: [1, 2, 3]}))

o.dig(:a, :a, :...
...b, 0) # => 1
o.dig(:b, 0) # => nil
//}

@see Array#dig, Hash#dig, OpenStruct#dig...

Integer#digits -> [Integer] (6208.0)

base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。

...の基数は 10 です。

//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}

self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。

//emlist[][ruby]{
-
10.digits # Math::DomainError: out of domain が発...

Integer#digits(base) -> [Integer] (6208.0)

base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。

...の基数は 10 です。

//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}

self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。

//emlist[][ruby]{
-
10.digits # Math::DomainError: out of domain が発...

絞り込み条件を変える

Float::DIG -> Integer (6203.0)

Float が表現できる最大の 10 進桁数です。

Float が表現できる最大の 10 進桁数です。

通常はデフォルトで 15 です。

Float::MANT_DIG -> Integer (6203.0)

仮数部の Float::RADIX 進法での桁数です。

仮数部の Float::RADIX 進法での桁数です。

通常はデフォルトで 53 です。

Time#ceil(ndigits=0) -> Time (346.0)

十進小数点数で指定した桁数の精度で切り上げをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で切り上げます)。

...ます)。

ndigits には 0 以上の整数を渡します。

@param ndigits 十進での精度(桁数)

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

t = Time.utc(2010,3,30, 5,43,25.0123456789r)
t.iso8601(10) # => "2010-03-30T05:43:25.0123456789Z"
t.ceil.iso8601(10) # => "2010-03-30T05:43:26.000...
....iso8601(10) # => "2010-03-30T05:43:26.0000000000Z"
t.ceil(1).iso8601(10) # => "2010-03-30T05:43:25.1000000000Z"
t.ceil(2).iso8601(10) # => "2010-03-30T05:43:25.0200000000Z"
t.ceil(3).iso8601(10) # => "2010-03-30T05:43:25.0130000000Z"
t.ceil(4).iso8601(10) # => "2010-03-30T05:43:25.0124000000Z"...
...2000-01-01T00:00:00.000Z"
(t + 0.9).ceil.iso8601(3) # => "2000-01-01T00:00:00.000Z"
(t + 1.4).ceil.iso8601(3) # => "2000-01-01T00:00:01.000Z"
(t + 1.9).ceil.iso8601(3) # => "2000-01-01T00:00:01.000Z"

t = Time.utc(1999,12,31, 23,59,59)
(t + 0.123456789).ceil(4).iso8601(6) # => "1999-12-31T...

Time#floor(ndigits=0) -> Time (346.0)

十進小数点数で指定した桁数の精度で切り捨てをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で切り捨てます)。

...ます)。

ndigits には 0 以上の整数を渡します。

@param ndigits 十進での精度(桁数)

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

t = Time.utc(2010,3,30, 5,43,25.123456789r)
t.iso8601(10) # => "2010-03-30T05:43:25.1234567890Z"
t.floor.iso8601(10) # => "2010-03-30T05:43:25.00...
...so8601(10) # => "2010-03-30T05:43:25.0000000000Z"
t.floor(1).iso8601(10) # => "2010-03-30T05:43:25.1000000000Z"
t.floor(2).iso8601(10) # => "2010-03-30T05:43:25.1200000000Z"
t.floor(3).iso8601(10) # => "2010-03-30T05:43:25.1230000000Z"
t.floor(4).iso8601(10) # => "2010-03-30T05:43:25.1234000000...
...99-12-31T23:59:59.000Z"
(t + 0.9).floor.iso8601(3) # => "1999-12-31T23:59:59.000Z"
(t + 1.4).floor.iso8601(3) # => "2000-01-01T00:00:00.000Z"
(t + 1.9).floor.iso8601(3) # => "2000-01-01T00:00:00.000Z"

t = Time.utc(1999,12,31, 23,59,59)
(t + 0.123456789).floor(4).iso8601(6) # => "1999-12-3...

Time#round(ndigits=0) -> Time (286.0)

十進小数点数で指定した桁数の精度で丸めをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で丸めます)。

...ます)。

ndigits には 0 以上の整数を渡します。

@param ndigits 十進での精度(桁数)

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

t = Time.utc(1999,12,31, 23,59,59)
p((t + 0.4).round.iso8601(3)) # => "1999-12-31T23:59:59.000Z"
p((t + 0.49).round.iso8601(3)) # => "1999-12-31T23:59:59....
...000Z"
p((t + 0.5).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.4).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.49).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.5).round.iso8601(3)) # => "2000-01-01T00:00:01.000Z"

t = Time.utc(1999,12,31, 23,59,59...
...)
p (t + 0.123456789).round(4).iso8601(6) # => "1999-12-31T23:59:59.123500Z"
//}...
...)
p (t + 0.123456789).round(4).iso8601(6) # => "1999-12-31T23:59:59.123500Z"
//}

@see Time#ceil, Time#floor...

絞り込み条件を変える

Integer#round(ndigits = 0, half: :up) -> Integer (226.0)

self ともっとも近い整数を返します。

...self ともっとも近い整数を返します。

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の...
...(-1) # => 20
(-15).round(-1) # => -20

25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -...
...30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}

@see Numeric#round...

Integer#round(ndigits = 0, half: :up) -> Integer | Float (226.0)

self ともっとも近い整数を返します。

...self ともっとも近い整数を返します。

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。...
...(-1) # => 20
(-15).round(-1) # => -20

25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -...
...30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}

@see Numeric#round...
<< 1 2 > >>