Module: Shoes::Common::ImageHandling
- Included in:
- Shoes::Color::DSLHelpers, Image, Swt::Image
- Defined in:
- shoes-core/lib/shoes/common/image_handling.rb
Instance Method Summary collapse
- #absolute_file_path(path) ⇒ Object
- #default_search_paths ⇒ Object
- #search_for(path, *locations) ⇒ Object
Instance Method Details
#absolute_file_path(path) ⇒ Object
6 7 8 9 10 11 12 |
# File 'shoes-core/lib/shoes/common/image_handling.rb', line 6 def absolute_file_path(path) if Pathname(path).absolute? search_for(File.basename(path), File.dirname(path)) else search_for(path, *default_search_paths) end end |
#default_search_paths ⇒ Object
25 26 27 |
# File 'shoes-core/lib/shoes/common/image_handling.rb', line 25 def default_search_paths [Dir.pwd, Shoes.configuration.app_dir, File.join(Shoes::DIR, "static")] end |
#search_for(path, *locations) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'shoes-core/lib/shoes/common/image_handling.rb', line 14 def search_for(path, *locations) found = locations.map { |dir| File.join(dir, path) } .find { |candidate| File.exist?(candidate) } unless found raise FileNotFoundError, "#{path} not found. Searched #{locations.join(',')}" end found end |