Class: CSSSprites::Sprite

Inherits:
Object
  • Object
show all
Defined in:
lib/css_sprites/sprite.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Sprite

Returns a new instance of Sprite.



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/css_sprites/sprite.rb', line 2

def initialize(path, options = {})
  validate_path(path)

  options[:name] ||= File.basename(path)

  @name = options[:name]
  @images = load_images(path)

  @image_grid = CSSSprites::ImageGrid.new(@images, options)
  @stylesheet = CSSSprites::SpriteStylesheet.new(@image_grid)
end

Instance Method Details

#imageObject



18
19
20
# File 'lib/css_sprites/sprite.rb', line 18

def image
  @image_grid.to_image
end

#nameObject



14
15
16
# File 'lib/css_sprites/sprite.rb', line 14

def name
  @name
end

#stylesheetObject



22
23
24
# File 'lib/css_sprites/sprite.rb', line 22

def stylesheet
  @stylesheet.to_s
end