Class: Consolidate::Image
- Inherits:
-
Object
- Object
- Consolidate::Image
- Defined in:
- lib/consolidate/image.rb
Instance Attribute Summary collapse
-
#aspect_ratio ⇒ Object
readonly
Returns the value of attribute aspect_ratio.
-
#dpi ⇒ Object
readonly
Returns the value of attribute dpi.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #contents ⇒ Object
-
#initialize(name:, width:, height:, path: nil, url: nil, contents: nil, dpix: nil, dpiy: nil) ⇒ Image
constructor
A new instance of Image.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, width:, height:, path: nil, url: nil, contents: nil, dpix: nil, dpiy: nil) ⇒ Image
Returns a new instance of Image.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/consolidate/image.rb', line 6 def initialize name:, width:, height:, path: nil, url: nil, contents: nil, dpix: nil, dpiy: nil @name = name @width = width @height = height @path = path @url = url @contents = contents @aspect_ratio = width.to_f / height.to_f # TODO: Read this from the contents @dpi = {x: dpix || 72, y: dpiy || 72} end |
Instance Attribute Details
#aspect_ratio ⇒ Object (readonly)
Returns the value of attribute aspect_ratio.
5 6 7 |
# File 'lib/consolidate/image.rb', line 5 def aspect_ratio @aspect_ratio end |
#dpi ⇒ Object (readonly)
Returns the value of attribute dpi.
5 6 7 |
# File 'lib/consolidate/image.rb', line 5 def dpi @dpi end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/consolidate/image.rb', line 5 def height @height end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/consolidate/image.rb', line 5 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/consolidate/image.rb', line 5 def width @width end |
Instance Method Details
#contents ⇒ Object
20 |
# File 'lib/consolidate/image.rb', line 20 def contents = @contents ||= contents_from_path || contents_from_url |
#to_s ⇒ Object
18 |
# File 'lib/consolidate/image.rb', line 18 def to_s = name |