Class: Imogen::Iiif::Rotation
- Defined in:
- lib/imogen/iiif/rotation.rb
Constant Summary collapse
- RIGHT_ANGLES =
[0,90,180,270]
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Transform
Constructor Details
This class inherits a constructor from Imogen::Iiif::Transform
Class Method Details
Instance Method Details
#get(rotate) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/imogen/iiif/rotation.rb', line 5 def get(rotate) if rotate.nil? or rotate.eql? '0' return nil end raise BadRequest.new("bad rotate #{rotate}") unless rotate =~ /^-?\d+$/ # negate offset because IIIF spec counts clockwise, FreeImage counterclockwise r = (rotate.to_i * -1) % 360 r = r + 360 if r < 0 raise BadRequest.new("bad rotate #{rotate}") unless RIGHT_ANGLES.include? r return r > 0 ? r : nil end |