Class: Typekit::Variation
- Inherits:
-
Object
- Object
- Typekit::Variation
- Includes:
- MassAssignment
- Defined in:
- lib/typekit/variation.rb
Overview
Move lazy loading into a module
Instance Attribute Summary collapse
-
#font_style ⇒ Object
Returns the value of attribute font_style.
-
#font_variant ⇒ Object
Returns the value of attribute font_variant.
-
#font_weight ⇒ Object
Returns the value of attribute font_weight.
-
#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.
-
#postscript_name ⇒ Object
Returns the value of attribute postscript_name.
Instance Method Summary collapse
-
#fetch(attribute) ⇒ Object
(also: #reload)
Get detailed information about this Family Variation from Typekit.
-
#to_fvd ⇒ String
Convert the variation name to the Font Variation Description for adding it to a Kit.
Methods included from MassAssignment
Instance Attribute Details
#font_style ⇒ Object
Returns the value of attribute font_style.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def font_style @font_style end |
#font_variant ⇒ Object
Returns the value of attribute font_variant.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def font_variant @font_variant end |
#font_weight ⇒ Object
Returns the value of attribute font_weight.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def font_weight @font_weight end |
#foundry ⇒ Object
Returns the value of attribute foundry.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def foundry @foundry end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def id @id end |
#libraries ⇒ Object
Returns the value of attribute libraries.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def libraries @libraries end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def name @name end |
#postscript_name ⇒ Object
Returns the value of attribute postscript_name.
5 6 7 |
# File 'lib/typekit/variation.rb', line 5 def postscript_name @postscript_name end |
Instance Method Details
#fetch(attribute) ⇒ Object Also known as: reload
This is called lazily when you access any non-loaded attribute and doesn’t need to be called manually unless you want to reload the data. This means we can return an array of Variation objects for Family#variations without making N+1 requests to the API.
Get detailed information about this Family Variation from Typekit
30 31 32 33 34 |
# File 'lib/typekit/variation.rb', line 30 def fetch(attribute) family_id, variation_id = @id.split(':') mass_assign Client.get("/families/#{family_id}/#{variation_id}") attribute ? instance_variable_get("@#{attribute}") : self end |
#to_fvd ⇒ String
Convert the variation name to the Font Variation Description for adding it to a Kit
39 40 41 |
# File 'lib/typekit/variation.rb', line 39 def to_fvd id.split(':').last end |