Class: EhbGameLib::MediaPath

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultEhbGameLib::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

Returns:

  • (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.expand_path.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

Returns:

  • (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.to_gosu_image_options)
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

#pathsArray

Returns:

  • (Array)


17
18
19
# File 'lib/ehb_game_lib/media_path.rb', line 17

def paths
  @paths ||= []
end