Sha256: 8689958e4f2085843e640fc8c7fbdf93d0376ee881c70ebb0327929aba150e36

Contents?: true

Size: 740 Bytes

Versions: 1

Compression:

Stored size: 740 Bytes

Contents

module Ray
  module ImageSet
    extend Ray::ResourceSet

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

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

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

begin
  require 'open-uri'

  Ray.image_set(/^(http|ftp):\/\/(\S+)$/) do |protocol, address|
    open("#{protocol}://#{address}") { |io| Ray::Image.new(io) }
  end
rescue LoadError
  # that image set is not needed
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ray-0.0.1 lib/ray/image_set.rb