Class: Hyde::FontFace
- Inherits:
-
Object
- Object
- Hyde::FontFace
- Defined in:
- lib/hyde_fonts/font_face.rb
Instance Attribute Summary collapse
-
#css ⇒ Object
Returns the value of attribute css.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
-
#initialize(face) ⇒ FontFace
constructor
A new instance of FontFace.
- #sort_variants ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(face) ⇒ FontFace
Returns a new instance of FontFace.
6 7 8 9 10 11 12 |
# File 'lib/hyde_fonts/font_face.rb', line 6 def initialize(face) @name = face["name"] @provider = face["provider"] @weights = face["weights"] @variants = parse_variants @css = [] end |
Instance Attribute Details
#css ⇒ Object
Returns the value of attribute css.
4 5 6 |
# File 'lib/hyde_fonts/font_face.rb', line 4 def css @css end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/hyde_fonts/font_face.rb', line 3 def name @name end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
3 4 5 |
# File 'lib/hyde_fonts/font_face.rb', line 3 def provider @provider end |
Instance Method Details
#sort_variants ⇒ Object
14 15 16 17 18 |
# File 'lib/hyde_fonts/font_face.rb', line 14 def sort_variants @variants.sort do |a, b| (a.italic == b.italic) ? a.weight <=> b.weight : a.italic <=> b.italic end end |
#to_s ⇒ Object
20 21 22 23 24 |
# File 'lib/hyde_fonts/font_face.rb', line 20 def to_s variants = sort_variants.map { |variant| variant.to_s } @name + ":ital,wght@" + variants.join(";") end |