class FontPair::Search

Search pairs for a specific typeface.

Attributes

pairs[R]

Public Class Methods

new(typeface, path) click to toggle source
# File lib/fontpair/search.rb, line 7
def initialize(typeface, path)
  @path = path
  @typeface = typeface.downcase
  @pairs = find_pairs
end

Public Instance Methods

pretty_print() click to toggle source
# File lib/fontpair/search.rb, line 13
def pretty_print
  if pairs.length.zero?
    $stderr.puts 'No pairs found'
    return
  end

  $stderr.puts 'You should consider the following pairs:'
  pairs.each { |pair| $stderr.puts "  + #{pair}" }
end

Private Instance Methods

find_pairs() click to toggle source
# File lib/fontpair/search.rb, line 25
def find_pairs
  font_pairs = File::readlines(@path)
  font_pairs.select { |pair| pair.downcase.match(@typeface) }
end