Class: SafeImage::Result
- Inherits:
-
Data
- Object
- Data
- SafeImage::Result
- Defined in:
- lib/safe_image/result.rb
Overview
Public image-operation return value. ‘output`/`output_format` are nil for metadata-only probes; image-producing operations always include them. `tier` records the concrete execution tier (for example :native_encode, :jpegtran_lossless or :jpegtran_fallback_reencode) so non-fatal degradation is observable without parsing the backend label.
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#filesize ⇒ Object
readonly
Returns the value of attribute filesize.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#input_format ⇒ Object
readonly
Returns the value of attribute input_format.
-
#optimizer ⇒ Object
readonly
Returns the value of attribute optimizer.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#output_format ⇒ Object
readonly
Returns the value of attribute output_format.
-
#tier ⇒ Object
readonly
Returns the value of attribute tier.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
- .build(input:, output: nil, input_format:, output_format: nil, width:, height:, backend:, duration_ms:, filesize: nil, optimizer: nil, encoder: nil, tier: nil) ⇒ Object
- .metadata(input:, input_format:, width:, height:, backend:, duration_ms:) ⇒ Object
- .result_filesize(input, output) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def backend @backend end |
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def duration_ms @duration_ms end |
#filesize ⇒ Object (readonly)
Returns the value of attribute filesize
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def filesize @filesize end |
#height ⇒ Object (readonly)
Returns the value of attribute height
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def height @height end |
#input ⇒ Object (readonly)
Returns the value of attribute input
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def input @input end |
#input_format ⇒ Object (readonly)
Returns the value of attribute input_format
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def input_format @input_format end |
#optimizer ⇒ Object (readonly)
Returns the value of attribute optimizer
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def optimizer @optimizer end |
#output ⇒ Object (readonly)
Returns the value of attribute output
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def output @output end |
#output_format ⇒ Object (readonly)
Returns the value of attribute output_format
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def output_format @output_format end |
#tier ⇒ Object (readonly)
Returns the value of attribute tier
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def tier @tier end |
#width ⇒ Object (readonly)
Returns the value of attribute width
13 14 15 |
# File 'lib/safe_image/result.rb', line 13 def width @width end |
Class Method Details
.build(input:, output: nil, input_format:, output_format: nil, width:, height:, backend:, duration_ms:, filesize: nil, optimizer: nil, encoder: nil, tier: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/safe_image/result.rb', line 27 def self.build( input:, output: nil, input_format:, output_format: nil, width:, height:, backend:, duration_ms:, filesize: nil, optimizer: nil, encoder: nil, tier: nil ) new( input: input.to_s, output: output&.to_s, input_format: input_format, output_format: output_format, width: width, height: height, filesize: filesize || result_filesize(input, output), backend: BackendLabel.build(backend, encoder: encoder), duration_ms: duration_ms, optimizer: optimizer, tier: tier ) end |
.metadata(input:, input_format:, width:, height:, backend:, duration_ms:) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/safe_image/result.rb', line 56 def self.(input:, input_format:, width:, height:, backend:, duration_ms:) build( input: input, input_format: input_format, width: width, height: height, filesize: File.size(input), backend: backend, duration_ms: duration_ms, tier: :metadata ) end |
.result_filesize(input, output) ⇒ Object
69 70 71 72 |
# File 'lib/safe_image/result.rb', line 69 def self.result_filesize(input, output) path = output || input path ? File.size(path) : nil end |
Instance Method Details
#success? ⇒ Boolean
74 |
# File 'lib/safe_image/result.rb', line 74 def success? = true |