Sha256: 96dca81b51429b5c881d51e082ba12e8eaba1729324f0693f4b0116224d39225

Contents?: true

Size: 869 Bytes

Versions: 49

Compression:

Stored size: 869 Bytes

Contents

module Pageflow
  class PositionedFile
    attr_reader :file, :position_x, :position_y

    delegate :thumbnail_url, to: :file

    def initialize(file, position_x = nil, position_y = nil)
      @file = file
      @position_x = position_x.presence || 50
      @position_y = position_y.presence || 50
    end

    def ==(other)
      super(other) ||
        other == file ||
        (other.is_a?(PositionedFile) && other.file == file)
    end

    def to_model
      file
    end

    def self.wrap(file, position_x, position_y)
      file ? new(file, position_x, position_y) : nil
    end

    def self.null
      Null.new
    end

    class Null < PositionedFile
      def initialize
        super(nil)
      end

      def thumbnail_url(*args)
        ImageFile.new.processed_attachment.url(*args)
      end

      def blank?
        true
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
pageflow-13.6.0 app/models/pageflow/positioned_file.rb
pageflow-13.5.0 app/models/pageflow/positioned_file.rb
pageflow-13.4.0 app/models/pageflow/positioned_file.rb
pageflow-13.3.0 app/models/pageflow/positioned_file.rb
pageflow-13.2.0 app/models/pageflow/positioned_file.rb
pageflow-12.6.0 app/models/pageflow/positioned_file.rb
pageflow-13.1.0 app/models/pageflow/positioned_file.rb
pageflow-12.5.0 app/models/pageflow/positioned_file.rb
pageflow-12.4.1 app/models/pageflow/positioned_file.rb
pageflow-13.0.0 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.rc1 app/models/pageflow/positioned_file.rb
pageflow-12.4.0 app/models/pageflow/positioned_file.rb
pageflow-12.3.0 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta7 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta6 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta5 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta4 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta3 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta2 app/models/pageflow/positioned_file.rb
pageflow-13.0.0.beta1 app/models/pageflow/positioned_file.rb