class TinyPng::Path
Public Class Methods
get_all(*list)
click to toggle source
Get all .png path names from the passed-in files and directories.
# 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
new(*show)
click to toggle source
Create a TinyPng::Path
object and optionally add .png paths to the show list (also transverses directories).
# File lib/tiny_png/path.rb, line 7 def initialize *show @show = TinyPng::Path.get_all show @blacklist = [] end
Public Instance Methods
add(*list)
click to toggle source
Add paths to the list (also transverses directories).
# File lib/tiny_png/path.rb, line 15 def add *list @show = (@show + TinyPng::Path.get_all(list)).uniq end
blacklist(*list)
click to toggle source
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.
# File lib/tiny_png/path.rb, line 24 def blacklist *list @blacklist = (@blacklist + TinyPng::Path.get_all(list)).uniq end
list()
click to toggle source
Return the full list of paths, minus anything in the blacklist.
# File lib/tiny_png/path.rb, line 45 def list @show.uniq - @blacklist end
remove_from_blacklist(*list)
click to toggle source
Remove paths from the blacklist (also transverses directories).
# File lib/tiny_png/path.rb, line 38 def remove_from_blacklist *list @blacklist = @blacklist - TinyPng::Path.get_all(list) end
remove_from_list(*list)
click to toggle source
Remove paths from the list (also transverses directories).
# File lib/tiny_png/path.rb, line 31 def remove_from_list *list @show = @show - TinyPng::Path.get_all(list) end