Class: Charming::Screen

Inherits:
Data
  • Object
show all
Defined in:
lib/charming/screen.rb

Overview

Screen represents the terminal viewport dimensions as a simple Data class. The ‘width` and `height` values flow from the backend through the runtime loop into every controller dispatch for layout calculations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height

Returns:

  • (Object)

    the current value of height



7
8
9
# File 'lib/charming/screen.rb', line 7

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width

Returns:

  • (Object)

    the current value of width



7
8
9
# File 'lib/charming/screen.rb', line 7

def width
  @width
end

Instance Method Details

#narrow?(below:, min_height: nil) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/charming/screen.rb', line 8

def narrow?(below:, min_height: nil)
  width < below && (min_height.nil? || height >= min_height)
end