Sha256: 25ce3cf09fde96b129cb60669c91c0c61d4265fb451e99424477c8bd8bb73521

Contents?: true

Size: 696 Bytes

Versions: 4

Compression:

Stored size: 696 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 image_set(regex, &block)
    Ray::ImageSet.add_set(regex, &block)
  end

  module_function :image_set
end

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

Version data entries

4 entries across 4 versions & 1 rubygems

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