Sha256: bf5e863029b3941af8bfdf1ea8ed0bd1f6e26e579d840faa2dee18c2c78fe492

Contents?: true

Size: 840 Bytes

Versions: 5

Compression:

Stored size: 840 Bytes

Contents

module Spontaneous::Media
  module Image
    class Attributes
      include Renderable

      attr_reader  :src, :width, :height, :filesize, :filepath

      def initialize(params={})
        params ||= {}
        @src, @width, @height, @filesize, @filepath = params.values_at(:src, :width, :height, :filesize, :path)
      end

      def serialize
        { :src => src, :width => width, :height => height, :filesize => filesize }
      end

      def inspect
        %(<#{self.class.name}: src=#{src.inspect} width="#{width}" height="#{height}">)
      end

      def blank?
        src.blank?
      end

      # Will only work for files in local storage
      def filepath
        Spontaneous::Media.to_filepath(src)
      end

      alias_method :empty?, :blank?

      def value(format = :html)
        src
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta9 lib/spontaneous/media/image/attributes.rb
spontaneous-0.2.0.beta8 lib/spontaneous/media/image/attributes.rb
spontaneous-0.2.0.beta7 lib/spontaneous/media/image/attributes.rb
spontaneous-0.2.0.beta6 lib/spontaneous/media/image/attributes.rb
spontaneous-0.2.0.beta5 lib/spontaneous/media/image/attributes.rb