Class: PureDocx::Constructors::ImageSize
- Inherits:
-
Object
- Object
- PureDocx::Constructors::ImageSize
- Defined in:
- lib/puredocx/constructors/image_size.rb
Constant Summary collapse
- MAX_IMAGE_WIDTH =
650
- PX_EMU =
8625
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#real_height ⇒ Object
readonly
Returns the value of attribute real_height.
-
#real_width ⇒ Object
readonly
Returns the value of attribute real_width.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(arguments = {}) ⇒ ImageSize
constructor
A new instance of ImageSize.
- #prepare_size ⇒ Object
Constructor Details
#initialize(arguments = {}) ⇒ ImageSize
Returns a new instance of ImageSize.
9 10 11 12 |
# File 'lib/puredocx/constructors/image_size.rb', line 9 def initialize(arguments = {}) @width, @height = arguments[:user_params] @real_width, @real_height = arguments[:real_params] end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
7 8 9 |
# File 'lib/puredocx/constructors/image_size.rb', line 7 def height @height end |
#real_height ⇒ Object (readonly)
Returns the value of attribute real_height.
7 8 9 |
# File 'lib/puredocx/constructors/image_size.rb', line 7 def real_height @real_height end |
#real_width ⇒ Object (readonly)
Returns the value of attribute real_width.
7 8 9 |
# File 'lib/puredocx/constructors/image_size.rb', line 7 def real_width @real_width end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
7 8 9 |
# File 'lib/puredocx/constructors/image_size.rb', line 7 def width @width end |
Instance Method Details
#prepare_size ⇒ Object
14 15 16 17 18 |
# File 'lib/puredocx/constructors/image_size.rb', line 14 def prepare_size new_width, new_height = set_new_size_params new_width, new_height = scaled_params(new_width, new_height) if new_width > MAX_IMAGE_WIDTH { width: new_width, height: new_height }.map { |key, value| [key, (value * PX_EMU)] }.to_h end |