Class: Arrolio::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#consumedObject (readonly)

Returns the value of attribute consumed.



5
6
7
# File 'lib/arrolio/frame.rb', line 5

def consumed
  @consumed
end

#heightObject (readonly)

Returns the value of attribute height.



5
6
7
# File 'lib/arrolio/frame.rb', line 5

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



5
6
7
# File 'lib/arrolio/frame.rb', line 5

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



5
6
7
# File 'lib/arrolio/frame.rb', line 5

def x
  @x
end

#yObject (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_emptyObject



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_yObject



28
29
30
# File 'lib/arrolio/frame.rb', line 28

def cursor_y
  @y + @height - @consumed
end

#full?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/arrolio/frame.rb', line 19

def full?
  remaining_height <= 0.5
end

#remaining_heightObject



15
16
17
# File 'lib/arrolio/frame.rb', line 15

def remaining_height
  @height - @consumed
end