Class: Typekit::Collection::Base
- Inherits:
-
Object
- Object
- Typekit::Collection::Base
- Extended by:
- Forwardable
- Includes:
- Enumerable, Typekit::Client::Proxy, Serialization
- Defined in:
- lib/typekit/collection/base.rb
Instance Attribute Summary
Attributes included from Typekit::Client::Proxy
Instance Method Summary collapse
-
#initialize(name, *arguments) ⇒ Base
constructor
A new instance of Base.
- #push(object) ⇒ Object (also: #<<)
Methods included from Serialization
Methods included from Typekit::Client::Proxy
Constructor Details
#initialize(name, *arguments) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 20 21 22 23 |
# File 'lib/typekit/collection/base.rb', line 15 def initialize(name, *arguments) objects = Helper.extract_array!(arguments) @elements = [] @klass = Element.classify(name) connect(arguments.first, name) objects.each { |object| push(object) } end |
Instance Method Details
#push(object) ⇒ Object Also known as: <<
25 26 27 28 29 30 31 32 |
# File 'lib/typekit/collection/base.rb', line 25 def push(object) if object.is_a?(klass) object.connect(self) elements << object else elements << klass.new(self, object) end end |