Class: Meatloaf::Ingredient
- Inherits:
-
Object
- Object
- Meatloaf::Ingredient
- Defined in:
- lib/meatloaf.rb
Overview
An Ingredient is simply one of the images to be compiled into the Sprite.
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#image_path ⇒ Object
Returns the value of attribute image_path.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x_offset ⇒ Object
Returns the value of attribute x_offset.
-
#y_offset ⇒ Object
Returns the value of attribute y_offset.
Instance Method Summary collapse
-
#initialize(image_css_url, x_offset = 0, y_offset = 0) ⇒ Ingredient
constructor
A new instance of Ingredient.
Constructor Details
#initialize(image_css_url, x_offset = 0, y_offset = 0) ⇒ Ingredient
Returns a new instance of Ingredient.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/meatloaf.rb', line 10 def initialize(image_css_url, x_offset = 0, y_offset = 0) @x_offset = x_offset @y_offset = y_offset # Find the asset associated with image_css_url. asset = Rails.application.assets.find_asset(image_css_url) raise ArgumentError.new("Can't find asset: #{image_css_url}") unless asset @image_path = asset.pathname.to_s # Get the dimensions of the image. @width, @height = `identify -format "%w %h" '#{@image_path}'`.chomp.split(' ').collect { |i| i.to_i } end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
8 9 10 |
# File 'lib/meatloaf.rb', line 8 def height @height end |
#image_path ⇒ Object
Returns the value of attribute image_path.
8 9 10 |
# File 'lib/meatloaf.rb', line 8 def image_path @image_path end |
#width ⇒ Object
Returns the value of attribute width.
8 9 10 |
# File 'lib/meatloaf.rb', line 8 def width @width end |
#x_offset ⇒ Object
Returns the value of attribute x_offset.
8 9 10 |
# File 'lib/meatloaf.rb', line 8 def x_offset @x_offset end |
#y_offset ⇒ Object
Returns the value of attribute y_offset.
8 9 10 |
# File 'lib/meatloaf.rb', line 8 def y_offset @y_offset end |