Class: Typekit::Family
- Inherits:
-
Object
- Object
- Typekit::Family
- Includes:
- MassAssignment
- Defined in:
- lib/typekit/family.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#foundry ⇒ Object
Returns the value of attribute foundry.
-
#id ⇒ Object
Returns the value of attribute id.
-
#libraries ⇒ Object
Returns the value of attribute libraries.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#variations ⇒ Object
Returns the value of attribute variations.
-
#web_link ⇒ Object
Returns the value of attribute web_link.
Class Method Summary collapse
-
.find(id) ⇒ Object
Retrieve a specific Family.
-
.find_by_name(name) ⇒ Object
Retrieve a Family by font family name.
-
.find_by_slug(slug) ⇒ Object
Retrieve a Family by Typekit slug.
Instance Method Summary collapse
-
#variation(id) ⇒ Object
Find a variation in this Family by the Font Variation Description.
Methods included from MassAssignment
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def description @description end |
#foundry ⇒ Object
Returns the value of attribute foundry.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def foundry @foundry end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def id @id end |
#libraries ⇒ Object
Returns the value of attribute libraries.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def libraries @libraries end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def slug @slug end |
#variations ⇒ Object
Returns the value of attribute variations.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def variations @variations end |
#web_link ⇒ Object
Returns the value of attribute web_link.
4 5 6 |
# File 'lib/typekit/family.rb', line 4 def web_link @web_link end |
Class Method Details
.find(id) ⇒ Object
Retrieve a specific Family
17 18 19 20 21 |
# File 'lib/typekit/family.rb', line 17 def find(id) family = Family.new Client.get("/families/#{id}") family.variations.map! { |v| Variation.send(:new, v) } family end |
.find_by_name(name) ⇒ Object
Retrieve a Family by font family name
32 33 34 |
# File 'lib/typekit/family.rb', line 32 def find_by_name(name) find_by_slug name.downcase.gsub(/[^a-z]+/, '-') end |
.find_by_slug(slug) ⇒ Object
Add error handling
Retrieve a Family by Typekit slug
26 27 28 |
# File 'lib/typekit/family.rb', line 26 def find_by_slug(slug) find(Client.get("/families/#{slug}")['id']) end |
Instance Method Details
#variation(id) ⇒ Object
Find a variation in this Family by the Font Variation Description
10 11 12 |
# File 'lib/typekit/family.rb', line 10 def variation(id) variations.select { |v| v.id.split(':').last == id }.first end |