Class: Arrolio::Frame
- Inherits:
-
Object
- Object
- Arrolio::Frame
- Defined in:
- lib/arrolio/frame.rb
Instance Attribute Summary collapse
-
#consumed ⇒ Object
readonly
Returns the value of attribute consumed.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #clone_empty ⇒ Object
- #consume!(h) ⇒ Object
- #cursor_y ⇒ Object
- #full? ⇒ Boolean
-
#initialize(x:, y:, width:, height:, consumed: 0.0) ⇒ Frame
constructor
A new instance of Frame.
- #remaining_height ⇒ Object
Constructor Details
#initialize(x:, y:, width:, height:, consumed: 0.0) ⇒ Frame
Returns a new instance of Frame.
7 8 9 10 11 12 13 |
# File 'lib/arrolio/frame.rb', line 7 def initialize(x:, y:, width:, height:, consumed: 0.0) @x = x.to_f @y = y.to_f @width = width.to_f @height = height.to_f @consumed = consumed.to_f end |
Instance Attribute Details
#consumed ⇒ Object (readonly)
Returns the value of attribute consumed.
5 6 7 |
# File 'lib/arrolio/frame.rb', line 5 def consumed @consumed end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/arrolio/frame.rb', line 5 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/arrolio/frame.rb', line 5 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
5 6 7 |
# File 'lib/arrolio/frame.rb', line 5 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
5 6 7 |
# File 'lib/arrolio/frame.rb', line 5 def y @y end |
Instance Method Details
#clone_empty ⇒ Object
32 33 34 |
# File 'lib/arrolio/frame.rb', line 32 def clone_empty self.class.new(x: @x, y: @y, width: @width, height: @height) end |
#consume!(h) ⇒ Object
23 24 25 26 |
# File 'lib/arrolio/frame.rb', line 23 def consume!(h) @consumed += h.to_f if h.to_f.positive? self end |
#cursor_y ⇒ Object
28 29 30 |
# File 'lib/arrolio/frame.rb', line 28 def cursor_y @y + @height - @consumed end |
#full? ⇒ Boolean
19 20 21 |
# File 'lib/arrolio/frame.rb', line 19 def full? remaining_height <= 0.5 end |
#remaining_height ⇒ Object
15 16 17 |
# File 'lib/arrolio/frame.rb', line 15 def remaining_height @height - @consumed end |