別のキーワード
ライブラリ
クラス
-
ARGF
. class (36) - Array (442)
- BasicObject (84)
- BigDecimal (204)
- Binding (30)
- CSV (24)
-
CSV
:: Table (108) - Class (12)
- Complex (36)
- Data (12)
- Dir (36)
- Enumerator (48)
- Fiber (30)
- Float (80)
- FrozenError (6)
-
Gem
:: Version (24) - Hash (454)
- IO (84)
- Integer (213)
- MatchData (24)
-
Matrix
:: LUPDecomposition (12) - Method (104)
- Module (324)
- Mutex (4)
- Numeric (103)
- Object (318)
-
OpenSSL
:: BN (132) - OpenStruct (19)
- OptionParser (204)
- Pathname (141)
- Proc (14)
-
REXML
:: Attributes (36) -
REXML
:: Child (24) -
REXML
:: Element (48) -
Rake
:: FileList (24) - Range (30)
- Rational (30)
-
Resolv
:: DNS :: Name (12) -
RubyVM
:: AbstractSyntaxTree :: Node (49) -
RubyVM
:: InstructionSequence (120) - Set (84)
- String (699)
- StringIO (38)
- Struct (53)
- Symbol (45)
- Thread (24)
-
Thread
:: Backtrace :: Location (72) -
Thread
:: ConditionVariable (24) -
Thread
:: Mutex (20) - Time (108)
- TracePoint (60)
- UnboundMethod (48)
-
WIN32OLE
_ TYPE (12)
モジュール
- Comparable (27)
- Enumerable (361)
-
OptionParser
:: Arguable (24)
キーワード
- ! (12)
- != (12)
- !~ (12)
- % (24)
- ** (11)
- + (12)
- < (46)
- << (38)
- <= (46)
- <=> (24)
- == (111)
- === (56)
- > (46)
- >= (46)
- >> (14)
- [] (108)
- []= (12)
-
_ dump (12) - abbrev (12)
- abs (36)
- abs2 (12)
- absolute? (12)
-
absolute
_ path (24) - allbits? (8)
- anybits? (8)
- append (8)
-
append
_ as _ bytes (1) -
backtrace
_ locations (24) -
base
_ label (24) - basename (12)
- between? (12)
- bind (12)
-
bind
_ call (12) - binmode (24)
- binread (12)
-
bit
_ length (12) - broadcast (12)
- bsearch (24)
-
bsearch
_ index (20) -
by
_ col! (12) -
by
_ col _ or _ row! (12) -
by
_ row! (12) - byterindex (3)
- bytes (38)
- call (24)
- casecmp? (9)
- ceil (24)
- chars (12)
- children (7)
-
chunk
_ while (12) - clamp (15)
- class (12)
-
class
_ eval (24) -
class
_ exec (12) -
clear
_ bit! (12) - closed? (12)
- codepoints (12)
- coerce (24)
- combination (24)
- compact (13)
- compact! (9)
-
compare
_ by _ identity (12) - concat (18)
- cover? (14)
- curry (22)
- deconstruct (3)
- default (24)
-
default
_ event _ sources (12) -
define
_ singleton _ method (24) - delete (12)
-
delete
_ if (24) - dig (30)
- digits (12)
- disable (24)
- disasm (12)
- disassemble (12)
- disjoint? (12)
- display (12)
- divmod (12)
- each (96)
-
each
_ byte (72) -
each
_ char (12) -
each
_ codepoint (12) -
each
_ cons (8) -
each
_ entry (24) -
each
_ grapheme _ cluster (8) -
each
_ key (24) -
each
_ pair (36) -
each
_ slice (8) -
each
_ value (24) -
each
_ with _ index (24) - empty? (9)
- enable (24)
- encode (36)
-
end
_ with? (18) - entries (7)
-
enum
_ for (24) - eql? (51)
- equal? (36)
- eval (24)
- extend (12)
-
extend
_ object (12) - extended (12)
-
fetch
_ values (22) - filter! (28)
- finite? (9)
-
first
_ column (7) -
first
_ lineno (19) - floor (24)
- fnmatch (12)
- freeze (12)
- friday? (12)
- getbyte (12)
- getc (12)
- gmt? (12)
-
grapheme
_ clusters (8) - gsub! (60)
-
has
_ elements? (12) - hash (12)
- include? (12)
- inherited (12)
-
initialize
_ copy (12) - inject (36)
- insert (12)
- inspect (37)
-
instance
_ eval (24) -
instance
_ exec (12) -
instance
_ method (12) - iseuc (12)
- itself (12)
-
keep
_ if (48) - label (24)
-
last
_ column (7) -
last
_ lineno (7) - lineno (12)
- lshift! (12)
- magnitude (24)
-
marshal
_ load (12) -
mask
_ bits! (12) - match (12)
- match? (18)
-
max
_ by (48) - merge (24)
- merge! (24)
-
mod
_ add (12) -
mod
_ exp (12) -
mod
_ inverse (12) -
mod
_ mul (12) -
mod
_ sub (12) -
module
_ eval (24) -
module
_ exec (12) - modulo (12)
- monday? (12)
- mountpoint? (12)
- namespace (12)
- namespaces (24)
- negative? (29)
- next (12)
- next! (12)
-
next
_ sibling= (12) - nobits? (8)
- nonzero? (24)
- on (144)
-
on
_ head (12) -
on
_ tail (12) - order! (24)
- overlap? (2)
- owned? (12)
- path (24)
- permutation (12)
- permute! (12)
- pos= (12)
- positive? (29)
- pow (22)
- prefixes (24)
- prepend (20)
-
prepend
_ features (12) - prerelease? (12)
-
pretty
_ print (12) -
previous
_ sibling= (12) -
proper
_ subset? (12) -
proper
_ superset? (12) - public (48)
-
public
_ class _ method (24) -
public
_ constant (12) -
public
_ instance _ method (12) - push (24)
- putc (12)
- raise (18)
- read (12)
- readlines (12)
- realpath (12)
- receiver (17)
- reduce (36)
- rehash (12)
- relative? (12)
-
relative
_ path _ from (12) - remainder (12)
-
repeated
_ combination (24) - replace (12)
- resume (12)
-
reverse
_ each (48) - rewind (12)
- root? (12)
- rotate! (12)
- rshift! (12)
- sample (24)
- saturday? (12)
- scan (24)
- scrub (36)
- scrub! (36)
- seek (12)
- select! (48)
-
set
_ bit! (12) - shift (12)
- signal (12)
-
singleton
_ class? (12) -
singleton
_ methods (12) - slice (72)
-
slice
_ when (12) - solve (12)
- sort (24)
- sort! (24)
-
sort
_ by (24) -
sort
_ by! (24) -
source
_ location (7) - split (14)
-
start
_ with? (18) - step (62)
- sub (24)
- sub! (48)
-
subdomain
_ of? (12) - subset? (12)
- subtract (12)
- succ (12)
- succ! (12)
- sum (24)
- sunday? (12)
- superset? (12)
- synchronize (12)
- taint (9)
- tally (10)
- tap (12)
- then (14)
- thursday? (12)
-
to
_ a (19) -
to
_ bn (12) -
to
_ enum (24) -
to
_ h (69) -
to
_ proc (12) -
to
_ s (54) -
transform
_ keys! (20) -
transform
_ values! (18) - trust (9)
- tuesday? (12)
- type (7)
- unbind (12)
-
undef
_ method (12) -
unicode
_ normalized? (11) - union (7)
- uniq (24)
- unshift (12)
- untaint (9)
- untrust (9)
- update (24)
- upto (12)
- utc? (12)
- wait (12)
-
wait
_ readable (12) - wednesday? (12)
-
yield
_ self (16) - zero? (12)
- zip (48)
検索結果
先頭5件
-
Object
# itself -> object (9223.0) -
self を返します。
...
self を返します。
//emlist[][ruby]{
string = 'my string' # => "my string"
string.itself.object_id == string.object_id # => true
//}... -
Object
# yield _ self -> Enumerator (9173.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...
self を引数としてブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すの......は良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerat......返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Thread
:: Backtrace :: Location # base _ label -> String (9123.0) -
self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。
...
self が表すフレームの基本ラベルを返します。通常、
Thread::Backtrace::Location#label から修飾を取り除いたもので構成
されます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)......end
end
Foo.new(0..2).locations.map do |call|
puts call.base_label
end
# => initialize
# new
# <main>
//}
@see Thread::Backtrace::Location#label... -
Module
# extend _ object(obj) -> object (6343.0) -
Object#extend の実体です。オブジェクトにモジュールの機能を追加します。
...Object#extend の実体です。オブジェクトにモジュールの機能を追加します。
Object#extend は、Ruby で書くと以下のように定義できます。
//emlist[例][ruby]{
def extend(*modules)
modules.reverse_each do |mod|
# extend_object や extended はプライ......で
# 直接 mod.extend_object(self) などとは書けない
mod.__send__(:extend_object, self)
mod.__send__(:extended, self)
end
end
//}
extend_object のデフォルトの実装では、self に定義されて
いるインスタンスメソッドを obj の特異メソッドとし......て追加します。
@param obj self の機能を追加するオブジェクトを指定します。
@return obj で指定されたオブジェクトを返します。
@see Module#extended... -
String
# bytes {|byte| . . . } -> self (6336.0) -
文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)
...列で返します。(self.each_byte.to_a と同じです)
//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}
ブロックが指定された場合は String#each_byte と同じように動作します。
Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除......されました。
@see String#each_byte... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (6320.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...列または正規表現で指定します。
offset が負の場合は、文字列の末尾から数えた位置から探索します。
byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません......mlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("in......[例][ruby]{
'foo'.byterindex('f') # => 0
'foo'.byterindex('o') # => 2
'foo'.byterindex('oo') # => 1
'foo'.byterindex('ooo') # => nil
'foo'.byterindex(/f/) # => 0
'foo'.byterindex(/o/) # => 2
'foo'.byterindex(/oo/) # => 1
'foo'.byterindex(/ooo/) # => nil
# 右でのマッチが優先
'foo'.byterin... -
String
# each _ byte {|byte| . . . } -> self (6308.0) -
文字列の各バイトに対して繰り返します。
...文字列の各バイトに対して繰り返します。
//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114
"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}
@see String#bytes... -
String
# gsub!(pattern , replace) -> self | nil (6271.0) -
文字列中で pattern にマッチする部分全てを文字列 replace に破壊的に置き換えます。
...に置き換えられます。
置換文字列内では \`、\'、\+ も使えます。
これらは $`、$'、$+ に対応します。
gsub! は通常 self を変更して返しますが、
置換が起こらなかった場合は nil を返します。
@param pattern 置き換える文字列......置き換える文字列
@return 置換した場合は self、置換しなかった場合は nil
//emlist[例][ruby]{
buf = "String-String"
buf.gsub!(/in./, "!!")
p buf # => "Str!!-Str!!"
buf = "String.String"
buf.gsub!(/in./, '<<\&>>')
p buf # => "Str<<ing>>-Str<<ing>>"
//}
注意:
引数 r......1 を使うことはできません。
replace は gsub メソッドの呼び出しより先に評価されるので、
まだ gsub の正規表現マッチが行われておらず、
$1 がセットされていないからです。
また、gsub では「\」が部分文字列との置き換えと... -
String
# sub!(pattern , replace) -> self | nil (6268.0) -
文字列中で pattern にマッチした最初の部分を文字列 replace へ破壊的に置き換えます。
...容に置き換えられます。
置換文字列内では \`、\'、\+ も使えます。
これらは $`、$'、$+ に対応します。
sub! は通常 self を変更して返しますが、
置換が起こらなかった場合は nil を返します。
@param pattern 置き換える文字列......置き換える文字列
@return 置換した場合は self、置換しなかった場合は nil
//emlist[例][ruby]{
buf = "String-String"
buf.sub!(/in./, "!!")
p buf # => "Str!!-String"
buf = "String.String"
buf.sub!(/in./, '<<\&>>')
p buf # => "Str<<ing>>-String"
//}
注意:
引数 replac......$1 を使うことはできません。
replace は sub メソッドの呼び出しより先に評価されるので、
まだ sub の正規表現マッチが行われておらず、
$1 がセットされていないからです。
また、sub では「\」が部分文字列との置き換えと... -
Object
# yield _ self {|x| . . . } -> object (6267.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) }
//}
ブロックなしで呼び出されたときは Enumerat......返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
ARGF
. class # binmode -> self (6266.0) -
self をバイナリモードにします。一度バイナリモードになった後は非バイナリ モードに戻る事はできません。
...
self をバイナリモードにします。一度バイナリモードになった後は非バイナリ
モードに戻る事はできません。
バイナリモード下では以下のように動作します。
* 改行の変換を停止する
* 文字エンコーディングの変換を停......ASCII-8BIT として扱う
例:
# test1.png - 164B
# test2.png - 128B
# test1.png + test2.png = 292B
# $ ruby test.rb test1.png test2.png
ARGF.binmode
ARGF.read.size # => 292
例:
# test1.png - 164B
# test2.png - 128B
# test1.png + test2.png = 292B
# $ ruby test.rb test1.p......ng test2.png
ARGF.read.size # => 290
@see IO#binmode, ARGF.class#binmode?...