るりまサーチ

最速Rubyリファレンスマニュアル検索!
861件ヒット [1-100件を表示] (0.134秒)

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. matrix i
  5. csv to_i

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

Integer#&(other) -> Integer (41218.0)

ビット二項演算子。論理積を計算します。

...ビット二項演算子。論理積を計算します。

@param other 数値

//emlist[][ruby]{
1 & 1 # => 1
2 & 3 # => 2
//}...

Integer#allbits?(mask) -> bool (26128.0)

self & mask の全てのビットが 1 なら true を返します。

...self & mask の全てのビットが 1 なら true を返します。

self & mask == mask と等価です。

@param mask ビットマスクを整数で指定します。

//emlist[][ruby]{
42.allbits?(42) # => true
0b1010_1010.allbits?(0b1000_0010) # => true
0b1010_1010.allbits?(...
...0b1000_0001) # => false
0b1000_0010.allbits?(0b1010_1010) # => false
//}

@see Integer#anybits?
@see Integer#nobits?...

Integer#anybits?(mask) -> bool (26128.0)

self & mask のいずれかのビットが 1 なら true を返します。

...elf & mask のいずれかのビットが 1 なら true を返します。

self & mask != 0 と等価です。

@param mask ビットマスクを整数で指定します。

//emlist[][ruby]{
42.anybits?(42) # => true
0b1010_1010.anybits?(0b1000_0010) # => true
0b1010_1010.anybits...
...?(0b1000_0001) # => true
0b1000_0010.anybits?(0b0010_1100) # => false
//}

@see Integer#allbits?
@see Integer#nobits?...

Integer#nobits?(mask) -> bool (26128.0)

self & mask のすべてのビットが 0 なら true を返します。

...self & mask のすべてのビットが 0 なら true を返します。

self & mask == 0 と等価です。

@param mask ビットマスクを整数で指定します。

//emlist[][ruby]{
42.nobits?(42) # => false
0b1010_1010.nobits?(0b1000_0010) # => false
0b1010_1010.nobits?(0...
...b1000_0001) # => false
0b0100_0101.nobits?(0b1010_1010) # => true
//}

@see Integer#allbits?
@see Integer#anybits?...

Integer#[](nth) -> Integer (23238.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...@return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1) と同じ
@return self[i...j] は (n >> i) & ((1 << (j - i)) - 1) と同じ
@return self[i..] は (n >> i) と同じ
@return self[..j] は n & ((1 << (j + 1))...
...urn self[...j] は n & ((1 << j) - 1) が 0 なら 0
@raise ArgumentError self[..j] で n & ((1 << (j + 1)) - 1) が 0 以外のとき
@raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 00000000...
...9**15
50.downto(0) {|n| print a[n] }
# => 000101110110100000111000011110010100111100010111001
//}

n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。

//emlist[][ruby]{
p 255[-1] # => 0
//}

//emlist[複数ビットの例][ruby]{
0b01001101[2, 4] #=> 0...

絞り込み条件を変える

Integer#[](nth, len) -> Integer (23238.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...@return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1) と同じ
@return self[i...j] は (n >> i) & ((1 << (j - i)) - 1) と同じ
@return self[i..] は (n >> i) と同じ
@return self[..j] は n & ((1 << (j + 1))...
...urn self[...j] は n & ((1 << j) - 1) が 0 なら 0
@raise ArgumentError self[..j] で n & ((1 << (j + 1)) - 1) が 0 以外のとき
@raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 00000000...
...9**15
50.downto(0) {|n| print a[n] }
# => 000101110110100000111000011110010100111100010111001
//}

n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。

//emlist[][ruby]{
p 255[-1] # => 0
//}

//emlist[複数ビットの例][ruby]{
0b01001101[2, 4] #=> 0...

Integer#[](range) -> Integer (23238.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...@return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1) と同じ
@return self[i...j] は (n >> i) & ((1 << (j - i)) - 1) と同じ
@return self[i..] は (n >> i) と同じ
@return self[..j] は n & ((1 << (j + 1))...
...urn self[...j] は n & ((1 << j) - 1) が 0 なら 0
@raise ArgumentError self[..j] で n & ((1 << (j + 1)) - 1) が 0 以外のとき
@raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 00000000...
...9**15
50.downto(0) {|n| print a[n] }
# => 000101110110100000111000011110010100111100010111001
//}

n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。

//emlist[][ruby]{
p 255[-1] # => 0
//}

//emlist[複数ビットの例][ruby]{
0b01001101[2, 4] #=> 0...

Integer#[](nth) -> Integer (23130.0)

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

...の数値
@return 1 か 0

//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010

a = 9**15
50.downto(0) {|n| print a[n] }
# => 000101110110100000111000011110010100111100010111001
//}

n[i] は (n >> i) & 1 と等価なので、負のインデ...
...ックスは常に 0 を返します。

//emlist[][ruby]{
p 255[-1] # => 0
//}


self[nth]=bit (つまりビットの修正) がないのは、Numeric 関連クラスが
i
mmutable であるためです。...

NilClass#&(other) -> false (21130.0)

常に false を返します。

...常に false を返します。

@param other 論理積を行なう式です

//emlist[例][ruby]{
nil & true # => false
nil & false # => false
nil & nil # => false
nil & "a" # => false
//}...

Dir.mkdir(path, mode = 0777) -> 0 (9128.0)

path で指定された新しいディレクトリを作ります。パーミッションは mode で指定された値に umask をかけた値 (mode & ~umask) になります。 mkdir(2) も参照して下さい。 ディレクトリの作成に成功すれば 0 を返します。

...(mode & ~umask) になります。
mkdir(2) も参照して下さい。
ディレクトリの作成に成功すれば 0 を返します。

@param path ディレクトリのパスを文字列で指定します。

@param mode ディレクトリのモードを整数で与えます。

@raise Errno::...
...EXXX ディレクトリの作成に失敗した場合に発生します。

//emlist[例][ruby]{
p File.umask #=> 2
Dir.mkdir('t', 0666)
p "%#o" % (07777 & File.stat('t').mode) #=> "0664"
//}

@see FileUtils.#makedirs...

絞り込み条件を変える

Module#ruby2_keywords(method_name, ...) -> nil (6243.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword arguments, the fi...
...ot include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed through the method to
other methods.

This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby v...
...s it does not exist in Ruby versions
before 2.7, check that the module responds to this method before calling
i
t. Also, be aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module Mod
def foo(meth, *args, &...

Pathname#each_line(*args) {|line| ... } -> nil (6240.0)

IO.foreach(self.to_s, *args, &block) と同じです。

...IO.foreach(self.to_s, *args, &block) と同じです。

//emlist[例][ruby]{
require "pathname"

I
O.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}

//emlist[例 ブロックを指定][ruby]{
require "pathname"

I
O.write("tes...
...tfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }

# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}

//emlist[例 limit を指定][ruby]{
require "pathname"

I
O.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }

# => "line"
# => "1\n"...
...# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}

//emlist[例 sep を指定][ruby]{
require "pathname"

I
O.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }

# => "line1\nline2,"
# => "\nline3\n"
//}

@see IO.foreach...

OptionParser#on_tail(*arg, &block) -> self (6225.0)

オプションを取り扱うためのブロックを自身の持つリストの最後に登録します。

...--version や --help の説明をサマリの最後に表示したい時に便利です。

@param arg OptionParser#on と同様です。

@param block OptionParser#on と同様です。

//emlist[例][ruby]{
require "optparse"

opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
op...
...ts.on_tail("-h", "--help")
end

puts opts.help

# => Usage: test [options]
# -i, --init
# -u, --update
# -h, --help
//}

//emlist[例][ruby]{
require "optparse"

opts = OptionParser.new
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end

opts.on_tail("--version", "S...
...how version") do
puts OptionParser::Version.join('.')
exit
end
//}

@see OptionParser#on, OptionParser#on_head...
<< 1 2 3 ... > >>