Class: Compass::SassExtensions::Sprites::Image

### Home Classes Methods

### In Files

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

### Parent

Object

### Methods

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

### Included Modules

- 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::Image

### Constants

ACTIVE
FOCUS
HOVER
NO_REPEAT
PARENT
REPEAT_X
REPEAT_Y
TARGET
VALID_REPEATS

### Attributes

base[R]
left[RW]
name[R]
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 21
    def initialize(base, relative_file, options)
      @base, @relative_file, @options = base, relative_file, options
      @left = @top = 0
      @name = File.basename(relative_file, '.png')
    end

### Public Instance Methods

active() click to toggle source

Active selector Image object if exsists

    # File lib/compass/sass_extensions/sprites/image.rb, line 134
    def active
      base.get_magic_selector_image(name, 'active')
    end

active?() click to toggle source

Is active selector

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

digest() click to toggle source

MD5 hash of this file

    # File lib/compass/sass_extensions/sprites/image.rb, line 99
    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 28
    def file
      @file ||= find_file
    end

find_file() click to toggle source

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

focus() click to toggle source

Active selector Image object if exsists

    # File lib/compass/sass_extensions/sprites/image.rb, line 144
    def focus
      base.get_magic_selector_image(name, 'focus')
    end

focus?() click to toggle source

Is active selector

    # File lib/compass/sass_extensions/sprites/image.rb, line 139
    def focus?
      name =~ FOCUS
    end

get_var_file(var) click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 55
    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 51
    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 114
    def hover
      base.get_magic_selector_image(name, 'hover')
    end

hover?() click to toggle source

Is hover selector

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

mtime() click to toggle source

mtime of this file

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

no_repeat?() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 79
    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 89
    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 148
    def parent
      if [hover?, target?, active?, focus?].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 84
    def position
      @position ||= get_var_file("position") || options.get_var("position") || number(0, "px")
    end

repeat() click to toggle source

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

    # File lib/compass/sass_extensions/sprites/image.rb, line 60
    def repeat
      @repeat ||= begin
        rep = (get_var_file("repeat") || options.get_var("repeat") || identifier(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 71
    def repeat_x?
      repeat == REPEAT_X
    end

repeat_y?() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 75
    def repeat_y?
      repeat == REPEAT_Y
    end

size() click to toggle source

    # File lib/compass/sass_extensions/sprites/image.rb, line 46
    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 94
    def spacing
      @spacing ||= (get_var_file("spacing") || options.get_var("spacing") || number(0, 'px')).value
    end

target() click to toggle source

Target selector Image object if exsists

    # File lib/compass/sass_extensions/sprites/image.rb, line 124
    def target
      base.get_magic_selector_image(name, 'target')
    end

target?() click to toggle source

Is target selector

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

width() click to toggle source

Width of the image

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.