class Compass::SassExtensions::Sprites::Image

Constants

ACTIVE
HOVER
PARENT
TARGET

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 13
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 99
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 94
def active?
  name =~ ACTIVE
end
digest() click to toggle source

MD5 hash of this file

# File lib/compass/sass_extensions/sprites/image.rb, line 64
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 19
def file
  File.join(Compass.configuration.images_path, relative_file)
end
height() click to toggle source

Height of the image

# File lib/compass/sass_extensions/sprites/image.rb, line 29
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 79
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 74
def hover?
  name =~ HOVER
end
mtime() click to toggle source

mtime of this file

# File lib/compass/sass_extensions/sprites/image.rb, line 69
def mtime
  File.mtime(file)
end
name() click to toggle source

Basename of the image

# File lib/compass/sass_extensions/sprites/image.rb, line 34
def name
  File.basename(relative_file, '.png')
end
offset() click to toggle source

Offset within the sprite

# File lib/compass/sass_extensions/sprites/image.rb, line 54
def 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 104
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 o 0px

# File lib/compass/sass_extensions/sprites/image.rb, line 49
def position
  options.get_var("#{name}-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 39
def repeat
  [ "#{name}-repeat", "repeat" ].each { |which|
    if var = options.get_var(which)
      return var.value
    end
  }
  "no-repeat"
end
spacing() click to toggle source

Spacing between this image and the next

# File lib/compass/sass_extensions/sprites/image.rb, line 59
def spacing
  (options.get_var("#{name}-spacing") || options.get_var("spacing") || Sass::Script::Number.new(0)).value
end
target() click to toggle source

Target selector Image object if exsists

# File lib/compass/sass_extensions/sprites/image.rb, line 89
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 84
def target?
  name =~ TARGET
end
width() click to toggle source

Width of the image

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