Class: Typekit::Library

Inherits:
Object
  • Object
show all
Includes:
MassAssignment
Defined in:
lib/typekit/library.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from MassAssignment

#initialize, #mass_assign

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/typekit/library.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/typekit/library.rb', line 4

def name
  @name
end

Class Method Details

.allObject

Gets a list of all the Typekit libraries



10
11
12
13
14
# File 'lib/typekit/library.rb', line 10

def all
  Client.get('/libraries').inject([]) do |libraries, attributes|
    libraries << Library.new(attributes)
  end
end

.find(id, params = {}) ⇒ Array

Gets a paginated list of families available in the specified library

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :page (Fixnum) — default: 1

    Page number to retrieve

  • :per_page (Fixnum) — default: 20

    Number of results to fetch per page

Returns:

  • (Array)

    Array of Typekit::Family objects available in the specified library



20
21
22
23
24
25
26
# File 'lib/typekit/library.rb', line 20

def find(id, params = {})
  { :page => 1, :per_page => 20 }.merge!(params)
  library = Client.get("/libraries/#{id}", :query => params)
  library['families'].inject([]) do |families, attributes|
    families << Family.new(attributes)
  end
end