Module: Spritely::SassFunctions
- Defined in:
- lib/spritely/sass_functions.rb
Instance Method Summary collapse
- #spritely_background(sprite_map, image_name) ⇒ Object
- #spritely_height(sprite_map, image_name) ⇒ Object
- #spritely_map(glob, kwargs = {}) ⇒ Object
- #spritely_position(sprite_map, image_name) ⇒ Object
- #spritely_url(sprite_map) ⇒ Object
- #spritely_width(sprite_map, image_name) ⇒ Object
Instance Method Details
#spritely_background(sprite_map, image_name) ⇒ Object
35 36 37 |
# File 'lib/spritely/sass_functions.rb', line 35 def spritely_background(sprite_map, image_name) Sass::Script::List.new([spritely_url(sprite_map), spritely_position(sprite_map, image_name)], :space) end |
#spritely_height(sprite_map, image_name) ⇒ Object
49 50 51 52 53 |
# File 'lib/spritely/sass_functions.rb', line 49 def spritely_height(sprite_map, image_name) image = find_image(sprite_map, image_name) Sass::Script::Number.new(image.height, ['px']) end |
#spritely_map(glob, kwargs = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/spritely/sass_functions.rb', line 5 def spritely_map(glob, kwargs = {}) SpriteMap.create(glob.value, kwargs).tap do |sprite_map| reset_sprockets_directory_cache! sprockets_context.depend_on(Spritely.directory) sprite_map.files.each do |file| sprockets_context.depend_on(file) sprockets_context.depend_on_asset(file) end end end |
#spritely_position(sprite_map, image_name) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/spritely/sass_functions.rb', line 24 def spritely_position(sprite_map, image_name) image = find_image(sprite_map, image_name) x = Sass::Script::Number.new(-image.left, image.left == 0 ? [] : ['px']) y = Sass::Script::Number.new(-image.top, image.top == 0 ? [] : ['px']) Sass::Script::List.new([x, y], :space) end |
#spritely_url(sprite_map) ⇒ Object
18 19 20 |
# File 'lib/spritely/sass_functions.rb', line 18 def spritely_url(sprite_map) asset_url(Sass::Script::String.new("sprites/#{sprite_map.name}.png")) end |
#spritely_width(sprite_map, image_name) ⇒ Object
41 42 43 44 45 |
# File 'lib/spritely/sass_functions.rb', line 41 def spritely_width(sprite_map, image_name) image = find_image(sprite_map, image_name) Sass::Script::Number.new(image.width, ['px']) end |