Sha256: 7cc563a0a44621d550e456f3cc10edf05be26b70265f4827307119057fa09e08

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 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?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta4 lib/spontaneous/media/image/attributes.rb
spontaneous-0.2.0.beta3 lib/spontaneous/media/image/attributes.rb
spontaneous-0.2.0.beta2 lib/spontaneous/media/image/attributes.rb