Class: EhbGameLib::MediaPath
- Inherits:
-
Object
- Object
- EhbGameLib::MediaPath
- Defined in:
- lib/ehb_game_lib/media_path.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find(subpath) ⇒ Pathname
- #load_bitmap_font(subpath, line_height) ⇒ EhbGameLib::Text::BitmapFont
- #load_gosu_image(subpath) ⇒ Gosu::Image
- #load_sprite(subpath) ⇒ EhbGameLib::Palettes::Sprite
- #paths ⇒ Array
Class Method Details
.default ⇒ EhbGameLib::MediaPath
11 12 13 |
# File 'lib/ehb_game_lib/media_path.rb', line 11 def default @default ||= new end |
Instance Method Details
#find(subpath) ⇒ Pathname
22 23 24 25 26 27 28 |
# File 'lib/ehb_game_lib/media_path.rb', line 22 def find(subpath) paths.each do |path| full_path = path.to_pathname..join(subpath) return full_path if full_path.exist? end raise "Subpath \"#{subpath}\" not found (Searched in: #{paths})" end |
#load_bitmap_font(subpath, line_height) ⇒ EhbGameLib::Text::BitmapFont
31 32 33 |
# File 'lib/ehb_game_lib/media_path.rb', line 31 def load_bitmap_font(subpath, line_height) ::EhbGameLib::Text::BitmapFont.new(find(subpath).to_path, line_height) end |
#load_gosu_image(subpath) ⇒ Gosu::Image
36 37 38 |
# File 'lib/ehb_game_lib/media_path.rb', line 36 def load_gosu_image(subpath) ::Gosu::Image.new(find(subpath).to_path, ::EhbGameLib::Palettes::Sprite.) end |
#load_sprite(subpath) ⇒ EhbGameLib::Palettes::Sprite
41 42 43 |
# File 'lib/ehb_game_lib/media_path.rb', line 41 def load_sprite(subpath) ::EhbGameLib::Palettes::Sprite.from_file(find(subpath)) end |
#paths ⇒ Array
17 18 19 |
# File 'lib/ehb_game_lib/media_path.rb', line 17 def paths @paths ||= [] end |