クラス
-
ARGF
. class (10) - Array (42)
- Bignum (10)
- Class (1)
- Complex (9)
- Dir (24)
- Encoding (5)
-
Encoding
:: Converter (12) -
Encoding
:: InvalidByteSequenceError (2) -
Encoding
:: UndefinedConversionError (2) - Enumerator (15)
-
Enumerator
:: Lazy (25) - Exception (1)
- File (45)
-
File
:: Stat (8) - Fixnum (9)
- Float (38)
- Hash (19)
- IO (35)
- Integer (11)
- MatchData (16)
- Method (1)
- Module (16)
- NilClass (2)
- Numeric (15)
- Object (6)
- Proc (1)
-
Process
:: Status (3) - Random (6)
- Range (3)
- Rational (24)
- Regexp (5)
-
RubyVM
:: InstructionSequence (6) - String (32)
- Struct (2)
- Symbol (1)
- SystemExit (1)
- Thread (7)
-
Thread
:: Backtrace :: Location (6) - Time (4)
- TracePoint (1)
- UnboundMethod (1)
モジュール
- Enumerable (33)
- FileTest (2)
- GC (6)
-
GC
:: Profiler (1) - Kernel (31)
- Math (27)
- ObjectSpace (3)
- Process (5)
キーワード
-
$ ? (1) -
$ LOAD _ PATH (1) - % (3)
- & (1)
- * (4)
- ** (4)
- + (4)
- - (5)
- -@ (1)
-
/ (4) - < (1)
- <= (1)
- <=> (2)
- == (4)
- > (1)
- >= (1)
- >> (1)
- ArgumentError (1)
- Float (1)
- INFINITY (1)
- Location (1)
- MACCROATIAN (1)
- MAX (1)
-
MAX
_ 10 _ EXP (1) -
MAX
_ EXP (1) - MIN (1)
-
MIN
_ 10 _ EXP (1) -
MIN
_ EXP (1) - MacCroatian (1)
- NAN (1)
- Rational (1)
-
STATELESS
_ ISO _ 2022 _ JP _ KDDI (1) -
Stateless
_ ISO _ 2022 _ JP _ KDDI (1) - [] (9)
-
abort
_ on _ exception= (2) -
absolute
_ path (3) - acos (1)
- acosh (1)
- allocate (1)
- angle (2)
-
append
_ features (1) - arg (2)
-
asciicompat
_ encoding (2) - asin (1)
- asinh (1)
-
at
_ exit (1) - atan (1)
- atan2 (1)
- atanh (1)
- atime (3)
- attr (3)
-
attr
_ accessor (1) -
attr
_ reader (1) -
attr
_ writer (1) - autoload (2)
-
backtrace
_ locations (3) -
base
_ label (1) - begin (1)
- binread (1)
- binwrite (1)
- birthtime (1)
- blockdev? (1)
- bsearch (2)
-
bsearch
_ index (1) - bytes (1)
- caller (3)
-
caller
_ locations (2) - captures (1)
- catch (2)
- cbrt (1)
- ceil (3)
- chardev? (1)
- chars (1)
- chdir (3)
- chroot (1)
- chunk (3)
-
chunk
_ while (1) -
clock
_ gettime (1) - codepoints (1)
- coerce (1)
- collect (3)
- collect! (1)
-
collect
_ concat (1) - combination (2)
- compatible? (1)
- compile (1)
- concat (2)
- conjugate (1)
- convert (1)
- convpath (1)
- cos (1)
- cosh (1)
- ctime (1)
- cycle (2)
- delete (1)
-
delete
_ at (1) -
delete
_ if (2) - denominator (5)
-
deprecate
_ constant (1) -
destination
_ encoding (3) -
destination
_ encoding _ name (2) - detect (1)
- directory? (2)
- div (2)
- divmod (1)
- downto (1)
- drop (1)
-
drop
_ while (2) - each (13)
-
each
_ byte (3) -
each
_ char (3) -
each
_ codepoint (1) -
each
_ cons (1) -
each
_ entry (1) -
each
_ index (1) -
each
_ key (1) -
each
_ line (6) -
each
_ object (2) -
each
_ pair (1) -
each
_ slice (1) -
each
_ value (1) -
each
_ with _ index (1) -
each
_ with _ object (1) - end (1)
- entries (2)
-
enum
_ for (2) - eql? (2)
- erf (1)
- erfc (1)
- executable? (1)
-
executable
_ real? (1) - exist? (1)
- exit (2)
- exit! (2)
- exp (1)
- fdatasync (1)
- fdiv (4)
- feed (1)
-
fetch
_ values (2) - file? (1)
- find (1)
-
find
_ all (2) -
find
_ index (2) -
flat
_ map (1) - flatten (2)
- flatten! (1)
- flock (1)
- floor (3)
- fnmatch (1)
- fnmatch? (1)
- foreach (6)
- fork (2)
- format (1)
- frexp (1)
- gamma (1)
-
garbage
_ collect (2) - glob (2)
- grep (3)
-
grep
_ v (3) - grpowned? (1)
- gsub (7)
- gsub! (4)
-
handle
_ interrupt (1) - hash (1)
- hypot (1)
- index (3)
- inspect (3)
- isatty (1)
-
keep
_ if (3) - key (1)
- label (1)
-
last
_ match (2) -
latest
_ gc _ info (2) - lazy (1)
- ldexp (1)
- lgamma (1)
- lines (6)
-
load
_ from _ binary _ extra _ data (1) - log (2)
- log10 (1)
- log2 (1)
- loop (1)
- lstat (2)
- map (3)
- map! (1)
- match (5)
-
max
_ by (2) -
min
_ by (2) -
minmax
_ by (1) - mkdir (1)
- modulo (3)
- mtime (1)
-
named
_ captures (1) - negative? (2)
- new (12)
- next (1)
-
next
_ float (1) -
next
_ values (1) - numerator (5)
- offset (2)
- open (6)
- owned? (1)
- pack (1)
- path (4)
- peek (1)
-
peek
_ values (1) - permutation (2)
- phase (2)
- pipe? (1)
- positive? (1)
-
post
_ match (1) -
pre
_ match (1) -
prepend
_ features (1) -
prev
_ float (1) -
primitive
_ convert (4) - printf (4)
- private (2)
-
private
_ class _ method (1) -
private
_ constant (1) -
private
_ instance _ methods (1) -
private
_ method _ defined? (1) -
private
_ methods (1) - quo (2)
- rand (8)
- rationalize (9)
-
raw
_ data (1) - read (3)
- readable? (1)
-
readable
_ real? (1) - readlines (3)
- readlink (1)
- realdirpath (1)
- realpath (1)
- reject (4)
- reject! (2)
- remainder (1)
-
remove
_ const (1) - reopen (2)
-
repeated
_ combination (2) -
repeated
_ permutation (2) - require (1)
-
require
_ relative (1) -
respond
_ to _ missing? (1) -
reverse
_ each (1) - rewind (1)
- rindex (2)
- rmdir (1)
- rotate (1)
- rotate! (1)
- round (3)
- scan (2)
-
search
_ convpath (1) - select (5)
- select! (3)
- setgid? (1)
- setuid? (1)
- sin (1)
- sinh (1)
- size (2)
- size? (1)
-
slice
_ after (4) -
slice
_ before (5) -
slice
_ when (2) - socket? (1)
-
sort
_ by (1) -
sort
_ by! (1) -
source
_ location (3) - split (1)
- sprintf (1)
- sqrt (1)
- start (1)
- stat (4)
- status (1)
- step (6)
- sticky? (1)
- strftime (1)
- sub (5)
- sub! (3)
- symlink? (2)
- sync= (1)
- sysopen (1)
- take (1)
-
take
_ while (4) - tan (1)
- tanh (1)
- terminate (1)
- times (1)
-
to
_ a (1) -
to
_ binary (1) -
to
_ enum (2) -
to
_ f (3) -
to
_ i (2) -
to
_ r (3) -
to
_ s (3) - tr (1)
- tr! (1)
-
tr
_ s (1) -
tr
_ s! (1) - truncate (6)
- tty? (1)
- union (1)
- unlink (1)
- unpack (1)
- update (4)
- upto (1)
- utime (1)
-
values
_ at (5) - wait2 (1)
- waitpid2 (1)
-
with
_ object (2) -
world
_ readable? (2) -
world
_ writable? (2) - writable? (1)
-
writable
_ real? (1) - write (2)
- zero? (1)
- zip (2)
検索結果
先頭5件
-
Integer
# denominator -> Integer (18343.0) -
分母(常に1)を返します。
分母(常に1)を返します。
@return 分母を返します。
//emlist[][ruby]{
10.denominator # => 1
-10.denominator # => 1
//}
@see Integer#numerator -
Integer
# numerator -> Integer (18343.0) -
分子(常に自身)を返します。
分子(常に自身)を返します。
@return 分子を返します。
//emlist[][ruby]{
10.numerator # => 10
-10.numerator # => -10
//}
@see Integer#denominator -
Module
# attr _ reader(*name) -> nil (18343.0) -
インスタンス変数 name の読み取りメソッドを定義します。
インスタンス変数 name の読み取りメソッドを定義します。
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
//}
@param name String または Symbol を 1 つ以上指定します。 -
Module
# attr _ writer(*name) -> nil (18343.0) -
インスタンス変数 name への書き込みメソッド (name=) を定義します。
インスタンス変数 name への書き込みメソッド (name=) を定義します。
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。 -
Module
# private(*name) -> self (18343.0) -
メソッドを private に設定します。
メソッドを private に設定します。
引数なしのときは今後このクラスまたはモジュール定義内で新規に定義さ
れるメソッドを関数形式でだけ呼び出せるように(private)設定します。
引数が与えられた時には引数によって指定されたメソッドを private に
設定します。
可視性については d:spec/def#limit を参照して下さい。
@param name 0 個以上の String または Symbol を指定します。
@raise NameError 存在しないメソッド名を指定した場合に発生します。
//emlist[例][ruby]{
class Foo
... -
Module
# private _ instance _ methods(inherited _ too = true) -> [Symbol] (18343.0) -
そのモジュールで定義されている private メソッド名 の一覧を配列で返します。
そのモジュールで定義されている private メソッド名
の一覧を配列で返します。
@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。
@see Object#private_methods, Module#instance_methods
//emlist[例][ruby]{
module Foo
def foo; end
private def bar; end
end
module Bar
include Foo
def baz; end
private def qux; end
end... -
Module
# private _ method _ defined?(name) -> bool (18343.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が private であるときに true を返します。 そうでなければ false を返します。
インスタンスメソッド name がモジュールに定義されており、
しかもその可視性が private であるときに true を返します。
そうでなければ false を返します。
@param name Symbol か String を指定します。
@see Module#method_defined?, Module#public_method_defined?, Module#protected_method_defined?
//emlist[例][ruby]{
module A
def method1() end
end
class B
private
def ... -
Numeric
# denominator -> Integer (18343.0) -
自身を Rational に変換した時の分母を返します。
自身を Rational に変換した時の分母を返します。
@return 分母を返します。
@see Numeric#numerator、Integer#denominator、Float#denominator、Rational#denominator、Complex#denominator -
Numeric
# numerator -> Integer (18343.0) -
自身を Rational に変換した時の分子を返します。
自身を Rational に変換した時の分子を返します。
@return 分子を返します。
@see Numeric#denominator、Integer#numerator、Float#numerator、Rational#numerator、Complex#numerator -
Object
# private _ methods(include _ inherited = true) -> [Symbol] (18343.0) -
そのオブジェクトが理解できる private メソッド名の一覧を返します。
そのオブジェクトが理解できる private メソッド名の一覧を返します。
@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。
@see Module#private_instance_methods,Object#methods,Object#singleton_methods -
Array
# concat(other) -> self (18325.0) -
配列 other を自身の末尾に破壊的に連結します。
配列 other を自身の末尾に破壊的に連結します。
@param other 自身と連結したい配列を指定します。
//emlist[例][ruby]{
array = [1, 2]
a = [3, 4]
array.concat a
p array # => [1, 2, 3, 4]
p a # => [3, 4] # こちらは変わらない
//} -
Complex
# denominator -> Integer (18325.0) -
分母を返します。
分母を返します。
以下のように、実部と虚部の分母の最小公倍数を整数で返します。
1 2 3+4i <- numerator(分子)
- + -i -> ----
2 3 6 <- denominator(分母)
//emlist[例][ruby]{
Complex('1/2+2/3i').denominator # => 6
Complex(3).numerator # => 1
//}
@see Complex#numerator -
Complex
# numerator -> Complex (18325.0) -
分子を返します。
分子を返します。
//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}
@see Complex#denominator -
ENV
. update(other) -> ENV (18325.0) -
ハッシュ other の内容を環境変数にマージします。重複するキー に対応する値は other の内容で上書きされます。
ハッシュ other の内容を環境変数にマージします。重複するキー
に対応する値は other の内容で上書きされます。
self と other に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブロックを呼び出して
その返す値を重複キーに対応する値にします。ブロック付きでない
場合は常に other の値を使います。
@param other 上書きするハッシュを指定します。 -
ENV
. update(other) {|key , self _ val , other _ val| . . . } -> ENV (18325.0) -
ハッシュ other の内容を環境変数にマージします。重複するキー に対応する値は other の内容で上書きされます。
ハッシュ other の内容を環境変数にマージします。重複するキー
に対応する値は other の内容で上書きされます。
self と other に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブロックを呼び出して
その返す値を重複キーに対応する値にします。ブロック付きでない
場合は常に other の値を使います。
@param other 上書きするハッシュを指定します。 -
Encoding
:: Converter # destination _ encoding -> Encoding (18325.0) -
変換先のエンコーディングを返します。
変換先のエンコーディングを返します。
@return 変換先のエンコーディング
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "euc-jp")
ec.destination_encoding #=> #<Encoding:EUC-JP>
//} -
Encoding
:: InvalidByteSequenceError # destination _ encoding -> Encoding (18325.0) -
エラーを発生させた変換の変換先のエンコーディングを Encoding オブジェクトで返します。
エラーを発生させた変換の変換先のエンコーディングを Encoding
オブジェクトで返します。
@see Encoding::InvalidByteSequenceError#source_encoding,
Encoding::UndefinedConversionError#destination_encoding -
Encoding
:: InvalidByteSequenceError # destination _ encoding _ name -> String (18325.0) -
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
@see Encoding::InvalidByteSequenceError#destination_encoding -
Encoding
:: MACCROATIAN -> Encoding (18325.0) -
MacCroatian エンコーディング。
MacCroatian エンコーディング。
Mac OS で使われる
8bit single-byteエンコーディングで、
クロアチア語、スベロニア語を取り扱うものです。
@see https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CROATIAN.TXT -
Encoding
:: MacCroatian -> Encoding (18325.0) -
MacCroatian エンコーディング。
MacCroatian エンコーディング。
Mac OS で使われる
8bit single-byteエンコーディングで、
クロアチア語、スベロニア語を取り扱うものです。
@see https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CROATIAN.TXT -
Encoding
:: STATELESS _ ISO _ 2022 _ JP _ KDDI -> Encoding (18325.0) -
stateless-ISO-2022-JP-KDDI エンコーディングです。
stateless-ISO-2022-JP-KDDI エンコーディングです。
stateless-ISO-2022-JP の亜種です。
KDDI の携帯電話で使われる絵文字が含まれています。
@see https://www.au.com/ezfactory/tec/spec/img/typeD.pdf -
Encoding
:: Stateless _ ISO _ 2022 _ JP _ KDDI -> Encoding (18325.0) -
stateless-ISO-2022-JP-KDDI エンコーディングです。
stateless-ISO-2022-JP-KDDI エンコーディングです。
stateless-ISO-2022-JP の亜種です。
KDDI の携帯電話で使われる絵文字が含まれています。
@see https://www.au.com/ezfactory/tec/spec/img/typeD.pdf -
Encoding
:: UndefinedConversionError # destination _ encoding -> Encoding (18325.0) -
エラーを発生させた変換の変換先のエンコーディングを Encoding オブジェクトで返します。
エラーを発生させた変換の変換先のエンコーディングを Encoding
オブジェクトで返します。
@see Encoding::UndefinedConversionError#source_encoding -
Encoding
:: UndefinedConversionError # destination _ encoding _ name -> String (18325.0) -
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
@see Encoding::UndefinedConversionError#destination_encoding -
File
. absolute _ path(file _ name , dir _ string=nil) -> String (18325.0) -
file_name を絶対パスに変換した文字列を返します。
file_name を絶対パスに変換した文字列を返します。
相対パスの場合はカレントディレクトリを基準とします。
dir_string を渡した場合はそのディレクトリを基準とします。
File.expand_path と異なり、 file_name 先頭が "~" である場合
それは展開されません。普通のディレクトリ名として処理されます。
//emlist[例][ruby]{
p Dir.getwd #=> "/home/matz/work/bar"
p ENV["HOME"] #=> "/home/mat... -
Float
# truncate -> Integer (18325.0) -
小数点以下を切り捨てて値を整数に変換します。
小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor -
GC
:: Profiler . raw _ data -> [Hash , . . . ] | nil (18325.0) -
GC のプロファイル情報を GC の発生ごとに Hash の配列 (:GC_INVOKE_TIME が早いもの順)で返します。GC::Profiler が有効になっ ていない場合は nil を返します。
GC のプロファイル情報を GC の発生ごとに Hash の配列
(:GC_INVOKE_TIME が早いもの順)で返します。GC::Profiler が有効になっ
ていない場合は nil を返します。
例:
GC::Profiler.enable
GC.start
GC::Profiler.raw_data
# => [
{
:GC_TIME=>1.3000000000000858e-05,
:GC_INVOKE_TIME=>0.010634999999999999,
:HEAP_USE_SIZE=>289640,
... -
IO
# fdatasync -> 0 (18325.0) -
IO のすべてのバッファされているデータを直ちにディスクに書き込みます。
IO のすべてのバッファされているデータを直ちにディスクに書き込みます。
fdatasync(2) をサポートしていない OS 上では代わりに
IO#fsync を呼びだします。
IO#fsync との違いは fdatasync(2) を参照してください。
@raise NotImplementedError fdatasync(2) も fsync(2) も
サポートされていない OS で発生します。
//emlist[例][ruby]{
require "tempfile"
Tempfile.open("testtmpfile") do |f|
f.print... -
IO
# isatty -> bool (18325.0) -
入出力ポートがttyに結合している時、真を返します。そうでない場合 false を返します。
入出力ポートがttyに結合している時、真を返します。そうでない場合 false を返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
File.new("testfile").isatty # => false
File.new("/dev/tty").isatty # => true
//} -
Method
# source _ location -> [String , Integer] | nil (18325.0) -
ソースコードのファイル名と行番号を配列で返します。
ソースコードのファイル名と行番号を配列で返します。
その手続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
@see Proc#source_location
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----
require '/tmp/foo'
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.source... -
Module
# append _ features(module _ or _ class) -> self (18325.0) -
モジュール(あるいはクラス)に self の機能を追加します。
モジュール(あるいはクラス)に self の機能を追加します。
このメソッドは Module#include の実体であり、
include を Ruby で書くと以下のように定義できます。
//emlist[例][ruby]{
def include(*modules)
modules.reverse_each do |mod|
# append_features や included はプライベートメソッドなので
# 直接 mod.append_features(self) などとは書けない
mod.__send__(:append_features, s... -
Module
# private _ class _ method(*name) -> self (18325.0) -
name で指定したクラスメソッド (クラスの特異メソッド) の 可視性を private に変更します。
name で指定したクラスメソッド (クラスの特異メソッド) の
可視性を private に変更します。
@param name 0 個以上の String または Symbol を指定します。
//emlist[例][ruby]{
module Foo
def self.foo; end
end
Foo.singleton_class.private_method_defined?(:foo) # => false
Foo.private_class_method(:foo) # => Foo
Foo.singleton_class.private_method_define... -
Numeric
# negative? -> bool (18325.0) -
self が 0 未満の場合に true を返します。そうでない場合に false を返します。
self が 0 未満の場合に true を返します。そうでない場合に false を返します。
//emlist[例][ruby]{
-1.negative? # => true
0.negative? # => false
1.negative? # => false
//}
@see Numeric#positive? -
Numeric
# truncate -> Integer (18325.0) -
0 から 自身までの整数で、自身にもっとも近い整数を返します。
0 から 自身までの整数で、自身にもっとも近い整数を返します。
//emlist[例][ruby]{
1.truncate #=> 1
1.2.truncate #=> 1
(-1.2).truncate #=> -1
(-1.5).truncate #=> -1
//}
@see Numeric#ceil, Numeric#floor, Numeric#round -
Proc
# source _ location -> [String , Integer] | nil (18325.0) -
ソースコードのファイル名と行番号を配列で返します。
ソースコードのファイル名と行番号を配列で返します。
その手続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
//emlist[例][ruby]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc {}").source_location # => ... -
Regexp
. last _ match(nth) -> String | nil (18325.0) -
整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。
整数 nth が 0 の場合、マッチした文字列を返します
($&)。それ以外では、nth 番目の括弧にマッチ
した部分文字列を返します($1,$2,...)。
対応する括弧がない場合やマッチしなかった場合には nil を返し
ます。
//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match(0) # => "ab"
p Regexp.last_match(1) # => "a"
p Regexp.last_match(2) ... -
RubyVM
:: InstructionSequence # absolute _ path -> String | nil (18325.0) -
self が表す命令シーケンスの絶対パスを返します。
self が表す命令シーケンスの絶対パスを返します。
self を文字列から作成していた場合は nil を返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.absolute_path
# => nil
例2: RubyVM::InstructionSequence.compile_file を使用した場合
# /tmp/method.... -
RubyVM
:: InstructionSequence # path -> String (18325.0) -
self が表す命令シーケンスの相対パスを返します。
self が表す命令シーケンスの相対パスを返します。
self の作成時に指定した文字列を返します。self を文字列から作成していた
場合は "<compiled>" を返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
# => "<compiled>"
例2: RubyVM::InstructionSequence.compi... -
RubyVM
:: InstructionSequence . load _ from _ binary _ extra _ data(binary) -> String (18325.0) -
バイナリフォーマットの文字列から埋め込まれたextra_dataを取り出します。
バイナリフォーマットの文字列から埋め込まれたextra_dataを取り出します。
//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
binary = iseq.to_binary("extra_data")
RubyVM::InstructionSequence.load_from_binary_extra_data(binary) # => extra_data
//}
@see RubyVM::InstructionSequence#to_binary -
String
# match(regexp , pos = 0) {|m| . . . } -> object (18325.0) -
regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。
regexp.match(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match を参照してください。
//emlist[例: regexp のみの場合][ruby]{
'hello'.match('(.)\1') # => #<MatchData "ll" 1:"l">
'hello'.match('(.)\1')[0] # => "ll"
'hello'.match(/(.)\1/)[0] # => "ll"
'hello'.match('xx') # => nil
//}
... -
Thread
# status -> String | false | nil (18325.0) -
生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。
生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず
れかで返します。正常終了したスレッドに対して false、例外によ
り終了したスレッドに対して nil を返します。
Thread#alive? が真を返すなら、このメソッドも真です。
例:
a = Thread.new { raise("die now") }
b = Thread.new { Thread.stop }
c = Thread.new { Thread.exit }
d = Thread.new { sleep }
d.kill ... -
TracePoint
# path -> String (18325.0) -
イベントが発生したファイルのパスを返します。
イベントが発生したファイルのパスを返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end
trace.enable
foo 1
//} -
UnboundMethod
# source _ location -> [String , Integer] | nil (18325.0) -
ソースコードのファイル名と行番号を配列で返します。
ソースコードのファイル名と行番号を配列で返します。
その手続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は 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]
/... -
MatchData
# offset(n) -> [Integer , Integer] | [nil , nil] (18070.0) -
n 番目の部分文字列のオフセットの配列 [start, end] を返 します。
n 番目の部分文字列のオフセットの配列 [start, end] を返
します。
//emlist[例][ruby]{
[ self.begin(n), self.end(n) ]
//}
と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#begin, MatchData#end -
MatchData
# offset(name) -> [Integer , Integer] | [nil , nil] (18070.0) -
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返
します。
//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}
と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\... -
MatchData
# begin(n) -> Integer | nil (18061.0) -
n 番目の部分文字列先頭のオフセットを返します。
n 番目の部分文字列先頭のオフセットを返します。
0 はマッチ全体を意味します。
n 番目の部分文字列がマッチしていなければ nilを返します。
@param n 部分文字列を指定する数値。
@raise IndexError 範囲外の n を指定した場合に発生します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil
p $~.begin(4... -
MatchData
# end(n) -> Integer | nil (18061.0) -
n 番目の部分文字列終端のオフセットを返します。
n 番目の部分文字列終端のオフセットを返します。
0 はマッチ全体を意味します。
n 番目の部分文字列がマッチしていなければ nil を返します。
@param n 部分文字列を指定する数値。
@raise IndexError 範囲外の n を指定した場合に発生します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.end(0) # => 6
p $~.end(1) # => 3
p $~.end(2) # => 6
p $~.end(3) # => nil
p $~.end(4) # => ... -
MatchData
# [](name) -> String | nil (18052.0) -
name という名前付きグループにマッチした文字列を返します。
name という名前付きグループにマッチした文字列を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 指定した名前が正規表現内に含まれていない場合に発生します
//emlist[例][ruby]{
/\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")[:cents] # => "67"
/(?<alpha>[a-zA-Z]+)|(?<num>\d+)/.match("aZq")[:num] # => nil
//} -
MatchData
# [](n) -> String | nil (18037.0) -
n 番目の部分文字列を返します。
n 番目の部分文字列を返します。
0 はマッチ全体を意味します。
n の値が負の時には末尾からのインデックスと見倣します(末尾の
要素が -1 番目)。n 番目の要素が存在しない時には nil を返します。
@param n 返す部分文字列のインデックスを指定します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
p $~[0] # => "foobar"
p $~[1] # => "foo"
... -
MatchData
# [](range) -> [String] (18037.0) -
Range オブジェクト range の範囲にある要素からなる部分配列を返します。
Range オブジェクト range の範囲にある要素からなる部分配列を返します。
@param range start..end 範囲式。
//emlist[例][ruby]{
/(foo)(bar)/ =~ "foobarbaz"
p $~[0..2] # => ["foobar", "foo", "bar"]
//} -
MatchData
# [](start , length) -> [String] (18037.0) -
start 番目から length 個の要素を含む部分配列を返します。
start 番目から length 個の要素を含む部分配列を返します。
//emlist[例][ruby]{
/(foo)(bar)/ =~ "foobarbaz"
p $~[0, 3] # => ["foobar", "foo", "bar"]
//}
@see Array#[] -
MatchData
# ==(other) -> bool (18025.0) -
self と other のマッチ対象になった文字列、元になった正規表現オブジェク ト、マッチした位置が等しければ true を返します。そうでない場合には false を返します。
self と other のマッチ対象になった文字列、元になった正規表現オブジェク
ト、マッチした位置が等しければ true を返します。そうでない場合には
false を返します。
@param other 比較対象のオブジェクトを指定します。
//emlist[文字列][ruby]{
s = "abc"
m1 = s.match("a")
m2 = s.match("b")
m1 == m2 # => false
m2 = s.match("a")
m1 == m2 # => true
//}
//emlist[正規表現][ruby]{
r = /abc/
m1 = r.mat... -
MatchData
# captures -> [String] (18025.0) -
$1, $2, ... を格納した配列を返します。
$1, $2, ... を格納した配列を返します。
MatchData#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
p $~.captures # => ["foo", "bar", nil]
//}
@see MatchData#to_a, MatchData#named_captures -
MatchData
# eql?(other) -> bool (18025.0) -
self と other のマッチ対象になった文字列、元になった正規表現オブジェク ト、マッチした位置が等しければ true を返します。そうでない場合には false を返します。
self と other のマッチ対象になった文字列、元になった正規表現オブジェク
ト、マッチした位置が等しければ true を返します。そうでない場合には
false を返します。
@param other 比較対象のオブジェクトを指定します。
//emlist[文字列][ruby]{
s = "abc"
m1 = s.match("a")
m2 = s.match("b")
m1 == m2 # => false
m2 = s.match("a")
m1 == m2 # => true
//}
//emlist[正規表現][ruby]{
r = /abc/
m1 = r.mat... -
MatchData
# named _ captures -> Hash (18025.0) -
名前付きキャプチャをHashで返します。
名前付きキャプチャをHashで返します。
Hashのキーは名前付きキャプチャの名前です。Hashの値はキーの名前に対応した名前付きグループのうち最後にマッチした文字列です。
//emlist[例][ruby]{
m = /(?<a>.)(?<b>.)/.match("01")
m.named_captures # => {"a" => "0", "b" => "1"}
m = /(?<a>.)(?<b>.)?/.match("0")
m.named_captures # => {"a" => "0", "b" => nil}
m = /(?<a>.)(?<a>.)/.match("0... -
MatchData
# to _ a -> [String] (18025.0) -
$&, $1, $2,... を格納した配列を返します。
$&, $1, $2,... を格納した配列を返します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
//}
@see MatchData#captures -
Thread
:: Backtrace :: Location (18025.0) -
Ruby のフレームを表すクラスです。
Ruby のフレームを表すクラスです。
Kernel.#caller_locations から生成されます。
//emlist[例1][ruby]{
# caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end
c(0..2).map do |call|
puts call.to_s
end
//}
例1の実行結果:
caller_locations.rb:2:in `a'
caller_locations... -
Enumerator
:: Lazy # chunk(initial _ state) {|elt , state| . . . } -> Enumerator :: Lazy (9925.0) -
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.chunk{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007f8bf18118f0>:each>>
1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]], [true, [3]], [false, [4, 5... -
Enumerator
:: Lazy # slice _ before(initial _ state) {|elt , state| bool } -> Enumerator :: Lazy (9925.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5], [6... -
Rational
# / (other) -> Rational | Float (9661.0) -
商を計算します。
商を計算します。
@param other 自身を割る数
other に Float を指定した場合は、計算結果を Float で返します。
//emlist[例][ruby]{
r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / 0.5 # => 1.5
r / Rational(1, 2) # => (3/2)
r / 0 # => ZeroDivisionError
//}
@raise ZeroD... -
Rational
# quo(other) -> Rational | Float (9661.0) -
商を計算します。
商を計算します。
@param other 自身を割る数
other に Float を指定した場合は、計算結果を Float で返します。
//emlist[例][ruby]{
r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / 0.5 # => 1.5
r / Rational(1, 2) # => (3/2)
r / 0 # => ZeroDivisionError
//}
@raise ZeroD... -
File
:: Stat . new(path) -> File :: Stat (9643.0) -
path に関する File::Stat オブジェクトを生成して返します。 File.stat と同じです。
path に関する File::Stat オブジェクトを生成して返します。
File.stat と同じです。
@param path ファイルのパスを指定します。
@raise Errno::ENOENT pathに該当するファイルが存在しない場合発生します。
//emlist[][ruby]{
p $:[0]
#=> 例
# "C:/Program Files/ruby-1.8/lib/ruby/site_ruby/1.8"
p File::Stat.new($:[0])
#=> 例
#<File::Stat dev=0x2, ino=0, mode=040755, nlink=1,... -
Enumerator
:: Lazy # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (9625.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/).... -
Enumerator
:: Lazy # grep _ v(pattern) {|item| . . . } -> Enumerator :: Lazy (9625.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/).t... -
Enumerator
:: Lazy # slice _ after(pattern) -> Enumerator :: Lazy (9625.0) -
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>
1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5).force
# => [[1, 2, 3], [4, 5, 6], [... -
Enumerator
:: Lazy # slice _ before(pattern) -> Enumerator :: Lazy (9625.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5], [6... -
Rational
# *(other) -> Rational | Float (9625.0) -
積を計算します。
積を計算します。
@param other 自身に掛ける数
other に Float を指定した場合は、計算結果を Float で返しま
す。
//emlist[例][ruby]{
r = Rational(3, 4)
r * 2 # => (3/2)
r * 4 # => (3/1)
r * 0.5 # => 0.375
r * Rational(1, 2) # => (3/8)
//} -
Rational
# **(other) -> Rational | Float (9625.0) -
冪(べき)乗を計算します。
冪(べき)乗を計算します。
@param other 自身を other 乗する数
other に Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、計算結果が無理数だった場合は Float
を返します。
//emlist[例][ruby]{
r = Rational(3, 4)
r ** Rational(2, 1) # => (9/16)
r ** 2 # => (9/16)
r ** 2.0 # => 0.5625
r ** Rational(1, 2) # => 0.866... -
Rational
# +(other) -> Rational | Float (9625.0) -
和を計算します。
和を計算します。
@param other 自身に足す数
other に Float を指定した場合は、計算結果を Float で返しま
す。
//emlist[例][ruby]{
r = Rational(3, 4)
r + Rational(1, 2) # => (5/4)
r + 1 # => (7/4)
r + 0.5 # => 1.25
//} -
Rational
# -(other) -> Rational | Float (9625.0) -
差を計算します。
差を計算します。
@param other 自身から引く数
other に Float を指定した場合は、計算結果を Float で返しま
す。
//emlist[例][ruby]{
r = Rational(3, 4)
r - 1 # => (-1/4)
r - 0.5 # => 0.25
//} -
Math
. # acos(x) -> Float (9415.0) -
x の逆余弦関数(arccosine)の値をラジアンで返します。
x の逆余弦関数(arccosine)の値をラジアンで返します。
@param x -1.0 <= x <= 1 の範囲内の実数
@return 返される値の範囲は [0, +π] です。
@raise TypeError x に数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.acos(0) == Math::PI/2 # => true
//}
@see ... -
Math
. # asin(x) -> Float (9415.0) -
x の逆正弦関数(arcsine)の値をラジアンで返します。
x の逆正弦関数(arcsine)の値をラジアンで返します。
@param x -1.0 <= x <= 1 の範囲内の実数
@return 返される値の範囲は[-π/2, +π/2] です。
@raise TypeError x に数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.asin(1) == Math::PI/2 # => true
//}
@se... -
Math
. # log(x) -> Float (9415.0) -
x の対数(logarithm)を返します。
x の対数(logarithm)を返します。
引数 x, b の両方に 0 を指定した場合は Float::NAN を返します。
@param x 正の実数を指定します。
@param b 底を指定します。省略した場合は自然対数(natural logarithm)を計算します。
@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。
@raise RangeError 引数のどちらかに実数以外の数値を指定した場合に発生します。
@raise DomainError 引数のどちらかに負の数を指定した場合に発生します。
//emlist[例][ru... -
Math
. # log(x , b) -> Float (9415.0) -
x の対数(logarithm)を返します。
x の対数(logarithm)を返します。
引数 x, b の両方に 0 を指定した場合は Float::NAN を返します。
@param x 正の実数を指定します。
@param b 底を指定します。省略した場合は自然対数(natural logarithm)を計算します。
@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。
@raise RangeError 引数のどちらかに実数以外の数値を指定した場合に発生します。
@raise DomainError 引数のどちらかに負の数を指定した場合に発生します。
//emlist[例][ru... -
Math
. # acosh(x) -> Float (9397.0) -
x の逆双曲線余弦関数(area hyperbolic cosine)の値を返します。
x の逆双曲線余弦関数(area hyperbolic cosine)の値を返します。
=== 定義
acosh(x) = log(x + sqrt(x * x - 1)) [x >= 1]
@param x x >= 1 の範囲の実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
@see Math.#cosh -
Math
. # cos(x) -> Float (9397.0) -
x の余弦関数(cosine)の値を返します。
x の余弦関数(cosine)の値を返します。
@param x 実数(ラジアンで与えます)
@return [-1, 1] の実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.cos(Math::PI) # => -1.0
//}
@see Math.#acos -
Math
. # gamma(x) -> Float (9397.0) -
x のガンマ関数の値を返します。
x のガンマ関数の値を返します。
@param x 実数
@raise TypeError xに数値以外を指定した場合に発生します。
@raise Math::DomainError x に負の整数、もしくは -∞ を渡した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
def fact(n) (1..n).inject(1) {|r,i| r*i } end
1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] }
# => [1, 1.0, 1... -
Math
. # lgamma(x) -> [Float , Integer] (9397.0) -
log(|gamma(x)|) と、gamma(x) の符号を返します。
log(|gamma(x)|) と、gamma(x) の符号を返します。
符号は +1 もしくは -1 で返されます。
@param x 実数
@raise TypeError xに数値以外を指定した場合に発生します。
@raise Math::DomainError x に -∞ を渡した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.lgamma(0) # => [Infinity, 1]
//}
@see Math.#gamma -
Math
. # log10(x) -> Float (9397.0) -
x の常用対数(common logarithm)を返します。
x の常用対数(common logarithm)を返します。
@param x 正の実数
@raise TypeError xに数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.log10(1) # => 0.0
Math.log10(10) # => 1.0
Math.log10(10**100) # => 100.0
//}
@see M... -
Math
. # log2(x) -> Float (9397.0) -
2 を底とする x の対数(binary logarithm)を返します。
2 を底とする x の対数(binary logarithm)を返します。
@param x 正の実数
@raise TypeError xに数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.log2(1) # => 0.0
Math.log2(2) # => 1.0
Math.log2(32768) # => 15.0
Math.log2(65... -
Math
. # sin(x) -> Float (9397.0) -
x の正弦関数(sine)の値を返します。
x の正弦関数(sine)の値を返します。
@param x 実数(ラジアンで与えます)
@return [-1, 1] の実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.sin(Math::PI/2) # => 1.0
//}
@see Math.#asin -
Math
. # sqrt(x) -> Float (9397.0) -
x の非負の平方根(principal square root)を返します。
x の非負の平方根(principal square root)を返します。
@param x 0または正の実数
@raise TypeError xに数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
0.upto(10) {|x|
p [x, Math.sqrt(x), Math.sqrt(x)**2]
}
# => [0, 0.0, 0.0]
# [1, 1.0, ... -
Math
. # tan(x) -> Float (9397.0) -
x の正接関数(tangent)の値を返します。
x の正接関数(tangent)の値を返します。
@param x 実数(ラジアンで与えます)
@return 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.tan(0) # => 0.0
//}
@see Math.#atan, Math.#atan2 -
Math
. # tanh(x) -> Float (9397.0) -
x の双曲線正接関数(hyperbolic tangent)の値を返します。
x の双曲線正接関数(hyperbolic tangent)の値を返します。
=== 定義
tanh(x) = sinh(x) / cosh(x)
@param x 実数
@return [-1, 1] の範囲の実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
@see Math.#atanh -
Float
# round(ndigits = 0) -> Integer | Float (9379.0) -
自身ともっとも近い整数もしくは実数を返します。
自身ともっとも近い整数もしくは実数を返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数点以下を四捨五入し、整数を返します。
ndigitsが0より大きいならば、小数点以下の指定された位で四捨五入されます。
ndigitsが0より小さいならば、小数点以上の指定された位で四捨五入されます。
@return 指定された引数に応じて、整数もしくは実数を返します。
ndigi... -
Math
. # asinh(x) -> Float (9379.0) -
x の逆双曲線正弦関数(area hyperbolic sine)の値を返します。
x の逆双曲線正弦関数(area hyperbolic sine)の値を返します。
=== 定義
asinh(x) = log(x + sqrt(x * x + 1))
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
@see Math.#sinh -
Math
. # cbrt(x) -> Float (9379.0) -
x の立方根(cubic root)を返します。
x の立方根(cubic root)を返します。
@param x 実数
@raise TypeError xに数値以外を指定した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
-9.upto(9) {|x|
p [x, Math.cbrt(x), Math.cbrt(x)**3]
}
# => [-9, -2.0800838230519, -9.0]
# [-8, -2.0, -8.0]
# [-7, -1.91293118277239, -7.0]
# [-6, -1.8... -
Math
. # cosh(x) -> Float (9379.0) -
x の双曲線余弦関数(hyperbolic cosine)の値を返します。
x の双曲線余弦関数(hyperbolic cosine)の値を返します。
=== 定義
cosh(x) = (exp(x) + exp(-x)) / 2
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
@see Math.#acosh -
Math
. # erf(x) -> Float (9379.0) -
x の誤差関数(error function)の値を返します。
x の誤差関数(error function)の値を返します。
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.erf(0) # => 0.0
//}
@see Math.#erfc -
Math
. # erfc(x) -> Float (9379.0) -
x の相補誤差関数(complementary error function)の値を返します。
x の相補誤差関数(complementary error function)の値を返します。
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.erfc(0) # => 1.0
//}
@see Math.#erf -
Math
. # exp(x) -> Float (9379.0) -
x の指数関数(exponential)の値を返します。
x の指数関数(exponential)の値を返します。
すなわち e の x 乗の値を返します(e は自然対数の底)。
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.exp(0) # => 1.0
Math.exp(1) # => 2.718281828459045
Math.exp(1.5) # => 4.4816890703380645
//}
@see ... -
Math
. # hypot(x , y) -> Float (9379.0) -
sqrt(x*x + y*y) を返します。
sqrt(x*x + y*y) を返します。
この値は x, y を直交する 2 辺とする直角三角形の斜辺(hypotenuse)の長さです。
@param x 実数
@param y 実数
@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。
@raise RangeError 引数のどちらかに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.hypot(3, 4) #=> 5.0
//} -
Math
. # ldexp(x , exp) -> Float (9379.0) -
実数 x に 2 の exp 乗をかけた数を返します。
実数 x に 2 の exp 乗をかけた数を返します。
@param x 実数
@param exp 整数。小数点以下切捨て。
@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。
@raise RangeError 引数のどちらかに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
fraction, exponent = Math.frexp(1234)
Math.ldexp(fraction, exponent) # => 1234.0
//} -
Math
. # sinh(x) -> Float (9379.0) -
x の双曲線正弦関数(hyperbolic sine)の値を返します。
x の双曲線正弦関数(hyperbolic sine)の値を返します。
=== 定義
sinh(x) = (exp(x) - exp(-x)) / 2
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
@see Math.#asinh -
Enumerator
. new(obj , method = :each , *args) -> Enumerator (9364.0) -
オブジェクト obj について、 each の代わりに method という 名前のメソッドを使って繰り返すオブジェクトを生成して返します。 args を指定すると、 method の呼び出し時に渡されます。
オブジェクト obj について、 each の代わりに method という
名前のメソッドを使って繰り返すオブジェクトを生成して返します。
args を指定すると、 method の呼び出し時に渡されます。
@param obj イテレータメソッドのレシーバとなるオブジェクト
@param method イテレータメソッドの名前を表すシンボルまたは文字列
@param args イテレータメソッドの呼び出しに渡す任意個の引数
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new(str, :each_byte)
p enum.map... -
Enumerator
:: Lazy # drop(n) -> Enumerator :: Lazy (9361.0) -
Enumerable#drop と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#drop と同じですが、配列ではなくEnumerator::Lazy を返します。
@param n 要素数を指定します。
@raise ArgumentError n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
1.step.lazy.drop(3)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop(3)>
1.step.lazy.drop(3).take(10).force
# => [4, 5, 6, 7, 8, 9, 10, 1... -
Enumerator
:: Lazy # take(n) -> Enumerator :: Lazy (9361.0) -
Enumerable#take と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#take と同じですが、配列ではなくEnumerator::Lazy を返します。
n が大きな数 (100000とか) の場合に備えて再定義されています。
配列が必要な場合は Enumerable#first を使って下さい。
@param n 要素数を指定します。
@raise ArgumentError n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
1.step.lazy.take(5)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:... -
Hash
# update(other) -> self (9361.0) -
selfとotherのハッシュの内容をマージ(統合)します。
selfとotherのハッシュの内容をマージ(統合)します。
デフォルト値はselfの設定のままです。
self と other に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブロックを呼び出して
その返す値を重複キーに対応する値にします。ブロック付きでない
場合は常に other の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージ後のse... -
Hash
# update(other) {|key , self _ val , other _ val| . . . } -> self (9361.0) -
selfとotherのハッシュの内容をマージ(統合)します。
selfとotherのハッシュの内容をマージ(統合)します。
デフォルト値はselfの設定のままです。
self と other に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブロックを呼び出して
その返す値を重複キーに対応する値にします。ブロック付きでない
場合は常に other の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージ後のse... -
Kernel
. # sprintf(format , *arg) -> String (9361.0) -
format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。
format 文字列を C 言語の sprintf と同じように解釈し、
引数をフォーマットした文字列を返します。
@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime
=== sprintf フォーマット
Ruby の sprintf フォーマットは基本的に C 言語の sprintf(3)
のものと同じです。ただし、short や long などの C 特有の型に対する修飾子が
ないこと、2進数の指示子(%b, %B)が存在すること、s...