Class: Metro::Font
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Metro::Font
- Defined in:
- lib/metro/font.rb
Overview
Font is a wrapper class for a Gosu::Font. This allows for additional data to be stored without relying on monkey-patching on functionality.
Class Method Summary collapse
-
.create(options) ⇒ Object
Return a font that matches the specified criteria.
-
.find_or_create(options) ⇒ Object
Return a font that matches the specified criteria.
Instance Method Summary collapse
-
#initialize(gosu_font) ⇒ Font
constructor
A new instance of Font.
-
#size ⇒ Object
An alias to Gosu::Font’s height method.
Constructor Details
#initialize(gosu_font) ⇒ Font
Returns a new instance of Font.
9 10 11 |
# File 'lib/metro/font.rb', line 9 def initialize(gosu_font) super(gosu_font) end |
Class Method Details
.create(options) ⇒ Object
Return a font that matches the specified criteria. Using the name, size, and window a font will be generated and stored in the cache.
that describe the font.
46 47 48 49 50 51 |
# File 'lib/metro/font.rb', line 46 def self.create() window, name, size = create_params() gosu_font = create_gosu_font(window,name,size) fonts["#{name}:#{size}:#{window}"] = gosu_font new(gosu_font) end |
.find_or_create(options) ⇒ Object
Return a font that matches the specified criteria. Using the name, size, and window a font will be generated or retrieved from the cache.
that describe the font.
28 29 30 31 32 |
# File 'lib/metro/font.rb', line 28 def self.find_or_create() window, name, size = create_params() gosu_font = fonts["#{name}:#{size}:#{window}"] gosu_font ? new(gosu_font) : create() end |
Instance Method Details
#size ⇒ Object
An alias to Gosu::Font’s height method
14 |
# File 'lib/metro/font.rb', line 14 def size ; height ; end |