Skip to content
Daisuke YAMAGUCHI edited this page Nov 1, 2016 · 12 revisions

要約

Siren::Compound とは、すべての Siren::Shape を内包可能なオブジェクトです。Siren::Shape クラスの派生クラスです。Siren::Shape オブジェクトのグループとして用いることができます。

特異メソッド

new(shape, ...) -> Compound
new([shape, ...], ...) -> Compound

Siren::Shape 型のオブジェクトを内包する Siren::Compound オブジェクトを生成します。

例) include Siren c1 = Compound.new box c2 = Compound.new box, box c3 = Compound.new [box] c4 = Compound.new [box, box] c5 = Compound.new [box, box], box c6 = Compound.new [box, box], [box, box]

インスタンスメソッド

push(shape) -> Compound
<<(shape) -> Compound

Siren::Compound オブジェクトに Siren::Shape オブジェクトを追加します。


delete(shape) -> Compound

Siren::Compound オブジェクトに内包される Siren::Shape オブジェクトを削除します。

例) include Siren mybox = box mycomp = Compound.new mybox p mycomp.subshapes.size # => 1 mycomp.delete mybox p mycomp.subshapes.size # => 0

補足

Compound が内包する Shape を取得する

目的に応じ、次のメソッドを利用します。

Clone this wiki locally