Class: IIIF::Image::Size::Percent

Inherits:
Object
  • Object
show all
Defined in:
lib/iiif/image/size/percent.rb

Overview

The width and height of the returned image is scaled to n% of the width and height of the extracted region. The aspect ratio of the returned image is the same as that of the extracted region.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(percentage) ⇒ Percent

Returns a new instance of Percent.

Parameters:

  • percentage (Float)


8
9
10
# File 'lib/iiif/image/size/percent.rb', line 8

def initialize(percentage)
  @percentage = percentage
end

Instance Attribute Details

#percentageObject (readonly)

Returns the value of attribute percentage.



12
13
14
# File 'lib/iiif/image/size/percent.rb', line 12

def percentage
  @percentage
end

Instance Method Details

#scaleFloat

Returns scale factor between 0 and 1.

Returns:

  • (Float)

    scale factor between 0 and 1



15
16
17
# File 'lib/iiif/image/size/percent.rb', line 15

def scale
  percentage / 100
end

#to_sObject



19
20
21
# File 'lib/iiif/image/size/percent.rb', line 19

def to_s
  "pct:#{percentage}"
end