Class: Fontist::FormulaPicker

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/formula_picker.rb

Instance Method Summary collapse

Constructor Details

#initialize(font_name, size_limit:, version:, smallest:, newest:) ⇒ FormulaPicker

Returns a new instance of FormulaPicker.

[View source]

5
6
7
8
9
10
11
12
13
# File 'lib/fontist/formula_picker.rb', line 5

def initialize(font_name, size_limit:, version:, smallest:, newest:)
  @font_name = font_name
  @size_limit = size_limit || Fontist.formula_size_limit_in_megabytes

  @options  = {}
  @version  = @options[:version]  = version  if version
  @smallest = @options[:smallest] = smallest if smallest
  @newest   = @options[:newest]   = newest   if newest
end

Instance Method Details

#call(formulas) ⇒ Object

[View source]

15
16
17
18
19
20
21
22
# File 'lib/fontist/formula_picker.rb', line 15

def call(formulas)
  return [] if formulas.empty?

  list = filter(formulas)
  return [] if list.empty?

  choose(list)
end