Sha256: 291da3b696b0db0684c47e154b480654ab2aaff814bedd2894b0d2e0728c3f04

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require 'caracal/core/models/image_model'
require 'caracal/errors'


module Caracal
  module Core
    
    # This module encapsulates all the functionality related to adding
    # images to the document.
    #
    module Images
      def self.included(base)
        base.class_eval do
          
          #-------------------------------------------------------------
          # Public Methods
          #-------------------------------------------------------------
          
          def img(url = nil, options={}, &block)
            options.merge!({ url: url }) if url
            
            model = Caracal::Core::Models::ImageModel.new(options, &block)
            if model.valid?
              contents << model
            else
              raise Caracal::Errors::InvalidModelError, 'Images require an URL and positive size/margin values.'
            end
            model
          end
          
        end
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caracal-0.1.1 lib/caracal/core/images.rb