るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

クラス

モジュール

キーワード

検索結果

Array#append(*obj) -> self (18109.0)

指定された obj を順番に配列の末尾に追加します。 引数を指定しなければ何もしません。

...
引数を指定しなければ何もしません。

@param obj 自身に追加したいオブジェクトを指定します。

//emlist[例][ruby]{
array = [1, 2, 3]
array.push 4
array.push [5, 6]
array.push 7, 8
p array # => [1, 2, 3, 4, [5, 6], 7, 8]
//}

@see Array#pop, Array#shift...

Module#append_features(module_or_class) -> self (6133.0)

モジュール(あるいはクラス)に self の機能を追加します。

... Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def include(*modules)
modules.reverse_each do |mod|
# append_features や included はプライベートメソッドなので
# 直接 mod.append_features(self) などとは書けない
mod.__send__(:append...

String#append_as_bytes(*objects) -> self (6133.0)

引数で与えたオブジェクトをバイト列として、self に破壊的に連結します。

...を越える場合は、最下位のバイトのみを使用します。

//emlist[例][ruby]{
s = "あ".b # => "\xE3\x81\x82"
s.encoding # => #<Encoding:BINARY (ASCII-8BIT)>
s.append_as_bytes("い") # => "\xE3\x81\x82\xE3\x81\x84"

# s << "い" では連結できな...
...
s << "い" # => "incompatible character encodings: BINARY (ASCII-8BIT) and UTF-8 (Encoding::CompatibilityError)
//}

//emlist[引数で整数を渡す例][ruby]{
t = ""
t.append_as_bytes(0x61) # => "a"
t.append_as_bytes(0x3062) # => "ab"
//}

@see String#<<, String#concat...

Array#push(*obj) -> self (3009.0)

指定された obj を順番に配列の末尾に追加します。 引数を指定しなければ何もしません。

...
引数を指定しなければ何もしません。

@param obj 自身に追加したいオブジェクトを指定します。

//emlist[例][ruby]{
array = [1, 2, 3]
array.push 4
array.push [5, 6]
array.push 7, 8
p array # => [1, 2, 3, 4, [5, 6], 7, 8]
//}

@see Array#pop, Array#shift...

Module#include(*mod) -> self (26.0)

モジュール mod をインクルードします。

...循環してしまうような include を行った場合に発生します。

//emlist[例][ruby]{
module M
end
module M2
include M
end
module M
include M2
end
//}

実行結果:

-:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from...
...を引き継ぐことです。
インクルードは多重継承の代わりに用いられており、 mix-in とも呼びます。

//emlist[例][ruby]{
class C
include FileTest
include Math
end

p C.ancestors

# => [C, Math, FileTest, Object, Kernel]
//}

モジュールの機能追加は、...
...メソッド探索の順序です)。

同じモジュールを二回以上 include すると二回目以降は無視されます。

//emlist[例][ruby]{
module M
end
class C1
include M
end
class C2 < C1
include M # この include は無視される
end

p C2.ancestors # => [C2, C1, M, Objec...

絞り込み条件を変える

Kernel.#open(file, mode_enc = "r", perm = 0666) -> IO (20.0)

file をオープンして、IO(Fileを含む)クラスのインスタンスを返します。

...して起動し、
コマンドの標準入出力に対してパイプラインを生成します

ファイル名が "|-" である時、open は Ruby の子プロセス
を生成し、その子プロセスとの間のパイプ(IOオブジェクト)を返し
ます。(このときの動作は、IO....
...プンします。
オープン時にファイルがすでに存在していれば
その内容を空にします。

: "a", WRONLY|CREAT|APPEND
ファイルを書き込みモードでオープンします。
出力は 常に ファイルの末尾に追加されます。
例え...
...された文字列にはそのBOMに対応するエンコーディングが設定されます。
//emlist[BOMでUTF-16BEかLEかを判別する例][ruby]{
File.open("utf16.txt", "rb:BOM|utf-16"){|file| "..." }
//}

int_encも指定されていた場合、入力された文字列をext_encでエン...

Kernel.#open(file, mode_enc = "r", perm = 0666) {|io| ... } -> object (20.0)

file をオープンして、IO(Fileを含む)クラスのインスタンスを返します。

...して起動し、
コマンドの標準入出力に対してパイプラインを生成します

ファイル名が "|-" である時、open は Ruby の子プロセス
を生成し、その子プロセスとの間のパイプ(IOオブジェクト)を返し
ます。(このときの動作は、IO....
...プンします。
オープン時にファイルがすでに存在していれば
その内容を空にします。

: "a", WRONLY|CREAT|APPEND
ファイルを書き込みモードでオープンします。
出力は 常に ファイルの末尾に追加されます。
例え...
...された文字列にはそのBOMに対応するエンコーディングが設定されます。
//emlist[BOMでUTF-16BEかLEかを判別する例][ruby]{
File.open("utf16.txt", "rb:BOM|utf-16"){|file| "..." }
//}

int_encも指定されていた場合、入力された文字列をext_encでエン...

String#concat(*arguments) -> self (15.0)

self に複数の文字列を破壊的に連結します。

...ます。

@param arguments 複数の文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "foo"
str.concat
p str # => "foo"

str = "foo"
str.concat "bar", "baz"
p str # => "foobarbaz"

str = "foo"
str.concat("!", 33, 33)
p str # => "foo!!!"
//}

@see String#append_as_bytes...

Class (14.0)

クラスのクラスです。

...のないクラスをクラスとして持っていて、Class はそのメタ
クラスのクラスです。この関係は少し複雑ですが、Ruby を利用するにあたっ
ては特に重要ではありません。

クラスとモジュールには

* クラスはインスタンスを作...
...すが、それ以外のほとんどの機能は Module から継
承されています。Module のメソッドのうち

* Module#module_function
* Module#extend_object
* Module#append_features
* Module#prepend_features
* Module#refine

は Class では未定義にされています。...

Module#included(class_or_module) -> () (14.0)

self が Module#include されたときに対象のクラスまたはモジュー ルを引数にしてインタプリタがこのメソッドを呼び出します。

...このメソッドを呼び出します。

@param class_or_module Module#include を実行したオブジェクト

//emlist[例][ruby]{
module Foo
def self.included(mod)
p "#{mod} include #{self}"
end
end
class Bar
include Foo
end
# => "Bar include Foo"
//}

@see Module#append_features...

絞り込み条件を変える

String#<<(other) -> self (10.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...ing) 相当の文字を末尾に追加します。

self を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "stringXXX"

str << "YYY"
p str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p str...

String#concat(other) -> self (10.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...ing) 相当の文字を末尾に追加します。

self を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "stringXXX"

str << "YYY"
p str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p str...