Class: Blight::RendersCenteredText

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

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ RendersCenteredText

Returns a new instance of RendersCenteredText.



81
82
83
# File 'lib/blight.rb', line 81

def initialize(window)
  @window = window
end

Instance Method Details

#render(text) ⇒ Object



85
86
87
88
89
# File 'lib/blight.rb', line 85

def render(text)
  center_x = @window.x + (@window.width - text.length) / 2
  center_y = @window.height / 2
  @window.print(text, center_x, center_y)
end