Sha256: c0fcafcbf0e5bb75494638f4df65ba45fe208e6aa90be3351a86aa0b744cc1ae

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

module Ray
  module FontSet
    extend Ray::ResourceSet

    class << self
      def missing_pattern(string)
        Ray::Font[string]
      end

      def select!(&block)
        super(&block)
        Ray::Font.select!(&block)
      end
    end
  end

  # Creates a new font set.
  #
  # @param [Regexp] regex Regular expression used to match file
  # @yield [*args] Block returning the font
  #
  # @yieldparam args Regex captures
  def font_set(regex, &block)
    Ray::FontSet.add_set(regex, &block)
  end

  module_function :font_set
end

require 'open-uri'
Ray.font_set(/^(http|ftp):\/\/(\S+)$/) do |protocol, address|
  open("#{protocol}://#{address}") { |io| Ray::Font.new(io) }
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ray-0.2.1 lib/ray/font_set.rb
ray-0.2.0 lib/ray/font_set.rb
ray-0.1.1 lib/ray/font_set.rb
ray-0.1.0 lib/ray/font_set.rb