Class: RScale::Processor::Geometry
- Inherits:
-
Object
- Object
- RScale::Processor::Geometry
- Defined in:
- lib/rscale/geometry.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
-
.from_file(file) ⇒ Object
parse geomerty from file using imagemagick identify command.
-
.parse(str) ⇒ Object
parse dimensions from WxH string (W - width, H - height).
Instance Method Summary collapse
- #horizontal? ⇒ Boolean
-
#initialize(w, h) ⇒ Geometry
constructor
A new instance of Geometry.
- #ratio ⇒ Object
- #square? ⇒ Boolean
- #to_crop_resize ⇒ Object
- #to_s ⇒ Object
- #vertical? ⇒ Boolean
Constructor Details
#initialize(w, h) ⇒ Geometry
Returns a new instance of Geometry.
5 |
# File 'lib/rscale/geometry.rb', line 5 def initialize(w, h) ; @width = w ; @height = h ; end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
3 4 5 |
# File 'lib/rscale/geometry.rb', line 3 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
3 4 5 |
# File 'lib/rscale/geometry.rb', line 3 def width @width end |
Class Method Details
Instance Method Details
#horizontal? ⇒ Boolean
7 |
# File 'lib/rscale/geometry.rb', line 7 def horizontal? ; width > height ; end |
#ratio ⇒ Object
9 |
# File 'lib/rscale/geometry.rb', line 9 def ratio ; width.to_f / height.to_f ; end |
#square? ⇒ Boolean
6 |
# File 'lib/rscale/geometry.rb', line 6 def square? ; width == height ; end |
#to_crop_resize ⇒ Object
11 |
# File 'lib/rscale/geometry.rb', line 11 def to_crop_resize ; horizontal? ? "#{width}x" : "x#{height}" ; end |
#to_s ⇒ Object
10 |
# File 'lib/rscale/geometry.rb', line 10 def to_s ; "#{width}x#{height}" ; end |
#vertical? ⇒ Boolean
8 |
# File 'lib/rscale/geometry.rb', line 8 def vertical? ; width < height ; end |