Class: Presto::Dimensions
- Inherits:
-
Struct
- Object
- Struct
- Presto::Dimensions
- Defined in:
- lib/presto/dimensions.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height
2 3 4 |
# File 'lib/presto/dimensions.rb', line 2 def height @height end |
#width ⇒ Object
Returns the value of attribute width
2 3 4 |
# File 'lib/presto/dimensions.rb', line 2 def width @width end |
Class Method Details
.resize(from_w, from_h, to_w = nil, to_h = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/presto/dimensions.rb', line 3 def self.resize from_w, from_h, to_w=nil, to_h=nil if to_w && to_h w = to_w h = to_h elsif to_w w = to_w scale_x = to_w / from_w.to_f h = (scale_x * from_h).round elsif to_h h = to_h scale_y = to_h / from_h.to_f w = (scale_y * from_w).round else w = from_w h = from_h end new(w, h) end |