Class: Kleya::Viewport
- Inherits:
-
Object
- Object
- Kleya::Viewport
- Defined in:
- lib/kleya/viewport.rb
Overview
Viewport dimensions
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether the viewports are equal.
-
#initialize(width:, height:) ⇒ Viewport
constructor
A new instance of Viewport.
-
#inspect ⇒ String
The inspection of the viewport.
-
#to_a ⇒ Array
The viewport dimensions.
-
#to_h ⇒ Hash
The viewport dimensions.
Constructor Details
#initialize(width:, height:) ⇒ Viewport
Returns a new instance of Viewport.
10 11 12 13 |
# File 'lib/kleya/viewport.rb', line 10 def initialize(width:, height:) @width = width @height = height end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/kleya/viewport.rb', line 6 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/kleya/viewport.rb', line 6 def width @width end |
Instance Method Details
#==(other) ⇒ Boolean
Returns whether the viewports are equal.
27 28 29 |
# File 'lib/kleya/viewport.rb', line 27 def ==(other) other.is_a?(Viewport) && width == other.width && height == other.height end |
#inspect ⇒ String
Returns the inspection of the viewport.
32 33 34 |
# File 'lib/kleya/viewport.rb', line 32 def inspect "#<#{self.class.name} @width=#{width} @height=#{height}>" end |
#to_a ⇒ Array
Returns the viewport dimensions.
21 22 23 |
# File 'lib/kleya/viewport.rb', line 21 def to_a [width, height] end |
#to_h ⇒ Hash
Returns the viewport dimensions.
16 17 18 |
# File 'lib/kleya/viewport.rb', line 16 def to_h { width:, height: } end |