Class: Compass::SassExtensions::Sprites::SpriteMap

### Home Classes Methods

### In Files

- lib/compass/sass_extensions/sprites/sprite_map.rb

### Parent

Sass::Script::Value::Base

### Methods

- ::from_uri
- ::new
- ::relative_name
- #inspect
- #method_missing
- #respond_to?
- #sort_method
- #to_s

### Included Modules

- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::LayoutMethods
- Sass::Script::Value::Helpers

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::Commands
- Compass::Commands::Base
- Compass::Commands::CleanProject
- Compass::Commands::CleanProjectOptionsParser
- Compass::Commands::CompileProjectOptionsParser
- Compass::Commands::ConfigurationOptionsParser
- Compass::Commands::CreateProject
- Compass::Commands::CreateProjectOptionsParser
- Compass::Commands::Default
- Compass::Commands::DefaultOptionsParser
- Compass::Commands::ExtensionCommand
- Compass::Commands::ExtensionOptionsParser
- Compass::Commands::ExtensionsOptionParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::PrintVersion
- Compass::Commands::ProjectBase
- Compass::Commands::ProjectStats
- Compass::Commands::Registry
- Compass::Commands::Sprite
- Compass::Commands::SpriteOptionsParser
- Compass::Commands::StampPattern
- Compass::Commands::StampPatternOptionsParser
- Compass::Commands::StatsOptionsParser
- Compass::Commands::StructureOptionsParser
- Compass::Commands::UnpackExtension
- Compass::Commands::UpdateProject
- Compass::Commands::ValidateProject
- Compass::Commands::ValidationOptionsParser
- Compass::Commands::VersionOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Serialization
- Compass::Deprecation
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::FilesystemConflict
- Compass::Installers
- Compass::Installers::BareInstaller
- Compass::Installers::Base
- Compass::Installers::Manifest
- Compass::Installers::Manifest::Entry
- Compass::Installers::ManifestInstaller
- Compass::Installers::TemplateContext
- Compass::Logger
- Compass::MissingDependency
- Compass::NullLogger
- Compass::SassCompiler
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::SassDeclarationHelper
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Sprites
- Compass::SassExtensions::Sprites::ChunkyPngEngine
- Compass::SassExtensions::Sprites::Engine
- Compass::SassExtensions::Sprites::Image
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::ImageRow
- Compass::SassExtensions::Sprites::Images
- Compass::SassExtensions::Sprites::Layout
- Compass::SassExtensions::Sprites::Layout::Diagonal
- Compass::SassExtensions::Sprites::Layout::Horizontal
- Compass::SassExtensions::Sprites::Layout::Smart
- Compass::SassExtensions::Sprites::Layout::SpriteLayout
- Compass::SassExtensions::Sprites::Layout::Vertical
- Compass::SassExtensions::Sprites::LayoutMethods
- Compass::SassExtensions::Sprites::RowFitter
- Compass::SassExtensions::Sprites::SpriteMap
- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SpriteException
- Compass::SpriteImporter
- Compass::Sprites
- Compass::Sprites::Binding
- Compass::Stats
- Compass::Stats::CssFile
- Compass::Stats::SassFile
- Compass::Stats::StatsVisitor
- Compass::TestCase
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::Functions
- QuickCache

No matching classes.

# 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 16
    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 37
    def initialize(sprites, path, name, context, kwargs)
      @image_names = sprites
      @path = path
      @name = name
      @kwargs = kwargs
      @kwargs['cleanup'] ||= bool(true)
      @kwargs['layout'] ||= identifier('vertical')
      @kwargs['sort_by'] ||= identifier('none')
      @images = nil
      @width = nil
      @height = nil
      @engine = nil
      @evaluation_context = context
      compute_image_metadata!
    end

relative_name(sprite) click to toggle source

    # File lib/compass/sass_extensions/sprites/sprite_map.rb, line 26
    def self.relative_name(sprite)
      sprite = File.expand_path(sprite)
      Compass.configuration.sprite_load_path.each do |path|
        path_with_slash = "#{File.expand_path(path)}/"

        if sprite.include?(path_with_slash)
          return sprite.gsub(path_with_slash, '')
        end
      end
    end

### Public Instance Methods

inspect() click to toggle source

    # File lib/compass/sass_extensions/sprites/sprite_map.rb, line 57
    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

    # File lib/compass/sass_extensions/sprites/sprite_map.rb, line 76
    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

    # File lib/compass/sass_extensions/sprites/sprite_map.rb, line 72
    def respond_to?(meth)
      super || @evaluation_context.respond_to?(meth)
    end

sort_method() click to toggle source

    # File lib/compass/sass_extensions/sprites/sprite_map.rb, line 53
    def sort_method
      @kwargs['sort_by'].value
    end

to_s(kwargs = self.kwargs) click to toggle source

    # File lib/compass/sass_extensions/sprites/sprite_map.rb, line 68
    def to_s(kwargs = self.kwargs)
      sprite_url(self).value
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.