Class: Typie
- Inherits:
-
Object
- Object
- Typie
- Defined in:
- lib/typie.rb
Class Method Summary collapse
-
.add_domains(*domains) ⇒ Object
(also: add_domain)
private
Add domains for Typekit to serve this Kit to.
-
.add_font(name, options = {}) ⇒ Object
private
Add a Family to the Kit.
-
.call_it(name) ⇒ Object
private
Set the name of the Kit.
-
.new_kit(options = {}, &block) ⇒ String
Add a Kit to Typekit.
Class Method Details
.add_domains(*domains) ⇒ Object (private) Also known as: add_domain
Add domains for Typekit to serve this Kit to
40 41 42 43 |
# File 'lib/typie.rb', line 40 def add_domains(*domains) @settings[:domains] << domains @settings[:domains].flatten! end |
.add_font(name, options = {}) ⇒ Object (private)
Add a Family to the Kit
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/typie.rb', line 50 def add_font(name, = {}) font = @typekit.family_by_name(name) if [:include_variations] # We're silently ignoring invalid variations variations = [:include_variations] & font.variations.map(&:to_fvd) else # Add all variations available by default variations = font.variations.map(&:to_fvd) end @fonts << { :id => font.id, :variations => variations } end |
.call_it(name) ⇒ Object (private)
Set the name of the Kit
34 35 36 |
# File 'lib/typie.rb', line 34 def call_it(name) @settings[:name] = name end |
.new_kit(options = {}, &block) ⇒ String
Add a Kit to Typekit
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/typie.rb', line 10 def new_kit( = {}, &block) raise 'Token required' unless [:token] # Setup Typie @typekit = Typekit::Client.new([:token]) @settings = { :name => 'Unnamed', :domains => [] } @fonts = [] # Wreak havoc instance_eval &block # Handle it all kit = @typekit.create_kit @settings @fonts.each do |font| kit.add_family(font[:id], :variations => font[:variations]) end kit.id end |