class Compass::SassExtensions::Sprites::SpriteMap
Attributes
engine[RW]
height[RW]
image_names[RW]
images[RW]
kwargs[RW]
map[RW]
name[RW]
path[RW]
width[RW]
Public Class Methods
from_uri(uri, context, kwargs)
click to toggle source
Initialize a new sprite object from a relative file path the path is
relative to the images_path
confguration option
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 15 def self.from_uri(uri, context, kwargs) uri = uri.value path, name = Compass::SpriteImporter.path_and_name(uri) files = Compass::SpriteImporter.files(uri) sprites = files.map do |sprite| relative_name(sprite) end new(sprites, path, name, context, kwargs) end
new(sprites, path, name, context, kwargs)
click to toggle source
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 35 def initialize(sprites, path, name, context, kwargs) @image_names = sprites @path = path @name = name @kwargs = kwargs @kwargs['cleanup'] ||= Sass::Script::Bool.new(true) @kwargs['layout'] ||= Sass::Script::String.new('vertical') @images = nil @width = nil @height = nil @engine = nil @evaluation_context = context validate! compute_image_metadata! end
relative_name(sprite)
click to toggle source
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 25 def self.relative_name(sprite) sprite = File.expand_path(sprite) Compass.configuration.sprite_load_path.each do |path| path = File.expand_path(path) if sprite.include?(path) return sprite.gsub("#{path}/", "") end end end
Public Instance Methods
inspect()
click to toggle source
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 51 def inspect puts 'images' @images.each do |img| puts img.file end puts "options" @kwargs.each do |k,v| puts "#{k}:#{v}" end end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 70 def method_missing(meth, *args, &block) if @evaluation_context.respond_to?(meth) @evaluation_context.send(meth, *args, &block) else super end end
respond_to?(meth)
click to toggle source
Calls superclass method
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 66 def respond_to?(meth) super || @evaluation_context.respond_to?(meth) end
to_s(kwargs = self.kwargs)
click to toggle source
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 62 def to_s(kwargs = self.kwargs) sprite_url(self).value end
Private Instance Methods
modulize()
click to toggle source
# File lib/compass/sass_extensions/sprites/sprite_map.rb, line 80 def modulize @modulize ||= Compass::configuration.sprite_engine.to_s.scan(/([^_.]+)/).flatten.map {|chunk| "#{chunk[0].chr.upcase}#{chunk[1..-1]}" }.join end