Class: Metro::AssetPath

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

Overview

An AssetPath searches through the various paths based on the path provided.

First it assumes the path is absolute, second it assuemts that path is within the game, and third it assumes it is within metro itself.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ AssetPath

Returns a new instance of AssetPath.



65
66
67
# File 'lib/metro/asset_path.rb', line 65

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



69
70
71
# File 'lib/metro/asset_path.rb', line 69

def path
  @path
end

Class Method Details

.with(path) ⇒ Object



61
62
63
# File 'lib/metro/asset_path.rb', line 61

def self.with(path)
  path.is_a?(AssetPath) ? path : new(path.to_s)
end

Instance Method Details

#absolute_asset?(path) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/metro/asset_path.rb', line 77

def absolute_asset?(path)
  asset_at_path? path
end

#filepathObject Also known as: to_s



71
72
73
74
75
# File 'lib/metro/asset_path.rb', line 71

def filepath
  @filepath ||= begin
    absolute_asset?(path) or game_asset?(path) or metro_asset?(path)
  end
end

#game_asset?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

def game_asset?(path)
  asset_at_path? asset_path(path)
end

#metro_asset?(path) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/metro/asset_path.rb', line 85

def metro_asset?(path)
  asset_at_path? metro_asset_path(path)
end