Class: Typekit::Collection::Base

Inherits:
Object
  • Object
show all
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

#client, #token

Instance Method Summary collapse

Methods included from Serialization

#serialize

Methods included from Typekit::Client::Proxy

#connect

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