Class: Uniword::Images::ImageInfo
- Inherits:
-
Object
- Object
- Uniword::Images::ImageInfo
- Defined in:
- lib/uniword/images/image_info.rb
Overview
Value object describing a single image in a document.
Immutable snapshot of image metadata: name, path, content type, byte size, and pixel dimensions (when available).
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(name:, path:, content_type:, size:, width: nil, height: nil) ⇒ ImageInfo
constructor
A new instance of ImageInfo.
-
#to_s ⇒ String
Human-readable representation.
Constructor Details
#initialize(name:, path:, content_type:, size:, width: nil, height: nil) ⇒ ImageInfo
Returns a new instance of ImageInfo.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/uniword/images/image_info.rb', line 28 def initialize(name:, path:, content_type:, size:, width: nil, height: nil) @name = name @path = path @content_type = content_type @size = size @width = width @height = height freeze end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
20 21 22 |
# File 'lib/uniword/images/image_info.rb', line 20 def content_type @content_type end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
20 21 22 |
# File 'lib/uniword/images/image_info.rb', line 20 def height @height end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/uniword/images/image_info.rb', line 20 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
20 21 22 |
# File 'lib/uniword/images/image_info.rb', line 20 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
20 21 22 |
# File 'lib/uniword/images/image_info.rb', line 20 def size @size end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
20 21 22 |
# File 'lib/uniword/images/image_info.rb', line 20 def width @width end |
Instance Method Details
#to_s ⇒ String
Human-readable representation.
42 43 44 45 |
# File 'lib/uniword/images/image_info.rb', line 42 def to_s dims = width && height ? " #{width}x#{height}" : "" "#{name} (#{content_type}, #{size} bytes#{dims})" end |