### Home Classes Methods

### In Files

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

### Parent

Object

### Methods

- ::new
- #active
- #active?
- #digest
- #file
- #find_file
- #get_var_file
- #height
- #hover
- #hover?
- #mtime
- #name
- #no_repeat?
- #offset
- #parent
- #position
- #repeat
- #repeat_x?
- #size
- #spacing
- #target
- #target?
- #width

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::Rails
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::BrowserSupport
- 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::GenerateGridBackground
- Compass::Commands::GridBackgroundOptionsParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::MemoryDebugger
- 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::WatchProject
- Compass::Commands::WatchProjectOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Serialization
- Compass::Error
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::Exec::SwitchUI
- Compass::FilesystemConflict
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::GridBuilder
- 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::PNG
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::Colors
- Compass::SassExtensions::Functions::Constants
- Compass::SassExtensions::Functions::CrossBrowserSupport
- Compass::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::SassExtensions::Functions::Display
- Compass::SassExtensions::Functions::Enumerate
- Compass::SassExtensions::Functions::Env
- Compass::SassExtensions::Functions::FontFiles
- Compass::SassExtensions::Functions::GradientSupport
- Compass::SassExtensions::Functions::GradientSupport::Assertions
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::SassExtensions::Functions::GradientSupport::Functions
- Compass::SassExtensions::Functions::GradientSupport::Gradient
- Compass::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::SassExtensions::Functions::ImageSize
- Compass::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::SassExtensions::Functions::ImageSize::JPEG
- Compass::SassExtensions::Functions::InlineImage
- Compass::SassExtensions::Functions::Lists
- Compass::SassExtensions::Functions::Math
- Compass::SassExtensions::Functions::Selectors
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Functions::Urls
- Compass::SassExtensions::Functions::Urls::FontUrl
- Compass::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::SassExtensions::Functions::Urls::ImageUrl
- Compass::SassExtensions::Functions::Urls::StylesheetUrl
- 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::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::Util
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Tree
- Sass::Tree::Node
- QuickCache

No matching classes.

# Compass::SassExtensions::Sprites::Image

### Constants

ACTIVE
HOVER
NO_REPEAT
PARENT
REPEAT_X
TARGET
VALID_REPEATS

### Attributes

base[R]
left[RW]
options[R]
relative_file[R]
top[RW]

### Public Class Methods

new(base, relative_file, options) click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 18
    def initialize(base, relative_file, options)
      @base, @relative_file, @options = base, relative_file, options
      @left = @top = 0
    end

### Public Instance Methods

active() click to toggle source

Active selector Image object if exsists

    # File lib/compass/sass_extensions/sprites/image.rb, line 131
    def active
      base.image_for("#{name}_active")
    end

active?() click to toggle source

Is active selector

    # File lib/compass/sass_extensions/sprites/image.rb, line 126
    def active?
      name =~ ACTIVE
    end

digest() click to toggle source

MD5 hash of this file

    # File lib/compass/sass_extensions/sprites/image.rb, line 96
    def digest
      Digest::MD5.file(file).hexdigest
    end

file() click to toggle source

The Full path to the image

    # File lib/compass/sass_extensions/sprites/image.rb, line 24
    def file
      @file ||= find_file
    end

find_file() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 28
    def find_file
      Compass.configuration.sprite_load_path.compact.each do |path|
        f = File.join(path, relative_file)
        if File.exists?(f)
          return f
        end
      end
    end

get_var_file(var) click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 56
    def get_var_file(var)
      options.get_var "#{base.name}_#{name}_#{var}"
    end

height() click to toggle source

Height of the image

    # File lib/compass/sass_extensions/sprites/image.rb, line 47
    def height
      dimensions.last
    end

hover() click to toggle source

Hover selector Image object if exsists

    # File lib/compass/sass_extensions/sprites/image.rb, line 111
    def hover
      base.image_for("#{name}_hover")
    end

hover?() click to toggle source

Is hover selector

    # File lib/compass/sass_extensions/sprites/image.rb, line 106
    def hover?
      name =~ HOVER
    end

mtime() click to toggle source

mtime of this file

    # File lib/compass/sass_extensions/sprites/image.rb, line 101
    def mtime
      File.mtime(file)
    end

name() click to toggle source

Basename of the image

    # File lib/compass/sass_extensions/sprites/image.rb, line 52
    def name
      File.basename(relative_file, '.png')
    end

no_repeat?() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 76
    def no_repeat?
      repeat == NO_REPEAT
    end

offset() click to toggle source

Offset within the sprite

    # File lib/compass/sass_extensions/sprites/image.rb, line 86
    def offset
      @offset ||= (position.unitless? || position.unit_str == "px") ? position.value : 0
    end

parent() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 136
    def parent
      if [hover?, target?, active?].any?
        PARENT.match name
        base.image_for($1)
      end
    end

position() click to toggle source

Value of `$#{name}-position` or `$position` defaults to `0px`

    # File lib/compass/sass_extensions/sprites/image.rb, line 81
    def position
      @position||= get_var_file("position") || options.get_var("position") || Sass::Script::Number.new(0, ["px"])
    end

repeat() click to toggle source

Value of `$#{name}-repeat` or `$repeat`

    # File lib/compass/sass_extensions/sprites/image.rb, line 61
    def repeat
      @repeat ||= begin
        rep = (get_var_file("repeat") || options.get_var("repeat") || Sass::Script::String.new(NO_REPEAT)).value
        unless VALID_REPEATS.include? rep
          raise SpriteException, "Invalid option for repeat \"#{rep}\" - valid options are #{VALID_REPEATS.join(', ')}"
        end

        rep
      end
    end

repeat_x?() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 72
    def repeat_x?
      repeat == REPEAT_X
    end

size() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 42
    def size
      @size ||= File.size(file)
    end

spacing() click to toggle source

Spacing between this image and the next

    # File lib/compass/sass_extensions/sprites/image.rb, line 91
    def spacing
      @spacing ||= (get_var_file("spacing") || options.get_var("spacing") || Sass::Script::Number.new(0, ['px'])).value
    end

target() click to toggle source

Target selector Image object if exsists

    # File lib/compass/sass_extensions/sprites/image.rb, line 121
    def target
      base.image_for("#{name}_target")
    end

target?() click to toggle source

Is target selector

    # File lib/compass/sass_extensions/sprites/image.rb, line 116
    def target?
      name =~ TARGET
    end

width() click to toggle source

Width of the image

    # File lib/compass/sass_extensions/sprites/image.rb, line 38
    def width
      dimensions.first
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.