Class: ImgToPdf::Dimension
- Inherits:
-
Struct
- Object
- Struct
- ImgToPdf::Dimension
- Defined in:
- lib/img_to_pdf/dimension.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
-
.from_array(ary) ⇒ Object
ImgToPdf::Dimension parsed.
Instance Method Summary collapse
-
#direction ⇒ :landscape, :portrait
Direction of dimension.
-
#justify_direction(target_direction) ⇒ ImgToPdf::Dimension
Justified dimension.
-
#pt_to_in ⇒ ImgToPdf::Dimension
points to inches.
-
#to_a ⇒ Array<(Float, Float)>
Array.
-
#transpose ⇒ ImgToPdf::Dimension
Transposed dimension.
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height
3 4 5 |
# File 'lib/img_to_pdf/dimension.rb', line 3 def height @height end |
#width ⇒ Object
Returns the value of attribute width
3 4 5 |
# File 'lib/img_to_pdf/dimension.rb', line 3 def width @width end |
Class Method Details
.from_array(ary) ⇒ Object
Returns ImgToPdf::Dimension parsed.
7 8 9 |
# File 'lib/img_to_pdf/dimension.rb', line 7 def from_array(ary) return new(width: ary[0], height: ary[1]) end |
Instance Method Details
#direction ⇒ :landscape, :portrait
Returns direction of dimension.
18 19 20 |
# File 'lib/img_to_pdf/dimension.rb', line 18 def direction return width > height ? :landscape : :portrait end |
#justify_direction(target_direction) ⇒ ImgToPdf::Dimension
Returns justified dimension.
29 30 31 |
# File 'lib/img_to_pdf/dimension.rb', line 29 def justify_direction(target_direction) return direction == target_direction ? dup : transpose end |
#pt_to_in ⇒ ImgToPdf::Dimension
points to inches.
36 37 38 39 |
# File 'lib/img_to_pdf/dimension.rb', line 36 def pt_to_in return self.class.new(width: ImgToPdf::Unit.convert_pt_to_in(width), height: ImgToPdf::Unit.convert_pt_to_in(height)) end |
#to_a ⇒ Array<(Float, Float)>
Returns array. ‘[width, height]`.
13 14 15 |
# File 'lib/img_to_pdf/dimension.rb', line 13 def to_a return [width, height] end |
#transpose ⇒ ImgToPdf::Dimension
Returns transposed dimension.
23 24 25 |
# File 'lib/img_to_pdf/dimension.rb', line 23 def transpose return self.class.new(width: height, height: width) end |