Parent

Included Modules

Class/Module Index [+]

Quicksearch

Compass::SassExtensions::Sprites::Image

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.