Class: TinyPng::Path
- Inherits:
-
Object
- Object
- TinyPng::Path
- Defined in:
- lib/tiny_png/path.rb
Class Method Summary collapse
-
.get_all(*list) ⇒ Object
Get all .png path names from the passed-in files and directories.
Instance Method Summary collapse
-
#add(*list) ⇒ Object
Add paths to the list (also transverses directories).
-
#blacklist(*list) ⇒ Object
Add paths to the list (also transverses directories).
-
#initialize(*show) ⇒ Path
constructor
Create a TinyPng::Path object and optionally add .png paths to the show list (also transverses directories).
-
#list ⇒ Object
Return the full list of paths, minus anything in the blacklist.
-
#remove_from_blacklist(*list) ⇒ Object
Remove paths from the blacklist (also transverses directories).
-
#remove_from_list(*list) ⇒ Object
Remove paths from the list (also transverses directories).
Constructor Details
Class Method Details
.get_all(*list) ⇒ Object
Get all .png path names from the passed-in files and directories.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tiny_png/path.rb', line 52 def self.get_all *list list.flatten.uniq.collect do |path| if path.is_a?(TinyPng::Path) path.list else if File.directory?(path) Dir.glob("#{path.gsub(/\/$/,'')}/**/*.png") else path.downcase.match(/\.png$/) ? path : nil end end end.flatten.uniq.compact end |
Instance Method Details
#add(*list) ⇒ Object
Add paths to the list (also transverses directories).
15 16 17 |
# File 'lib/tiny_png/path.rb', line 15 def add *list @show = (@show + TinyPng::Path.get_all(list)).uniq end |
#blacklist(*list) ⇒ Object
Add paths to the list (also transverses directories). The blacklist supercedes the add list, such that any path added to the blacklist will not show up in the final compilation.
24 25 26 |
# File 'lib/tiny_png/path.rb', line 24 def blacklist *list @blacklist = (@blacklist + TinyPng::Path.get_all(list)).uniq end |
#list ⇒ Object
Return the full list of paths, minus anything in the blacklist.
45 46 47 |
# File 'lib/tiny_png/path.rb', line 45 def list @show.uniq - @blacklist end |