Sha256: 21bb3ec820eaca722d4837285332a0094da667f3992c3d2c8ee59a697ccdf046

Contents?: true

Size: 667 Bytes

Versions: 12

Compression:

Stored size: 667 Bytes

Contents

module IIIF::Image
  # Represents the size of a rectangle
  class Dimension
    def initialize(height:, width:)
      @height = height
      @width = width
    end

    attr_reader :height, :width

    # @param scale [Float] scale factor between 0 and 1
    # @return [Dimension]
    def scale(scale)
      Dimension.new(height: height * scale, width: width * scale)
    end

    # Return true if both dimensions of other are greater
    def enclosed_by?(other)
      width <= other.width && height <= other.height
    end

    def ==(other)
      width == other.width && height == other.height
    end

    def aspect
      Rational(width, height)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
iiif-image-api-0.3.0 lib/iiif/image/models/dimension.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/iiif-image-api-0.2.0/lib/iiif/image/models/dimension.rb
iiif-image-api-0.2.0 lib/iiif/image/models/dimension.rb
iiif-image-api-0.1.0 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.8 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.7 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.6 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.5 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.4 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.3 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.2 lib/iiif/image/models/dimension.rb
iiif-image-api-0.0.1 lib/iiif/image/models/dimension.rb