module Fontina::Format
Public Class Methods
for(criteria)
click to toggle source
# File lib/fontina/format.rb, line 5 def for(criteria) criteria.lazy .map { |key, value| registry[key][value] } .find(&:itself) or fail "no format matches #{criteria}" end
Private Class Methods
register(format, criteria)
click to toggle source
# File lib/fontina/format.rb, line 13 def register(format, criteria) criteria.each do |key, args| args.each { |arg| registry[key][arg] = format } end end
registry()
click to toggle source
# File lib/fontina/format.rb, line 19 def registry @registry ||= %i[extension mime_type] .reduce(Hash.new({}.freeze)) { |h, k| h[k] = {}; h } end