Class: TurnKit::MediaAnalysisResult
- Inherits:
-
Object
- Object
- TurnKit::MediaAnalysisResult
- Defined in:
- lib/turnkit/media_analysis_result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#media ⇒ Object
readonly
Returns the value of attribute media.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Class Method Summary collapse
Instance Method Summary collapse
- #cost ⇒ Object
- #data? ⇒ Boolean (also: #structured?)
-
#initialize(text: "", data: nil, model: nil, provider: nil, usage: Usage.new, params: {}, media: {}, metadata: {}, error: nil) ⇒ MediaAnalysisResult
constructor
A new instance of MediaAnalysisResult.
- #to_h ⇒ Object
Constructor Details
#initialize(text: "", data: nil, model: nil, provider: nil, usage: Usage.new, params: {}, media: {}, metadata: {}, error: nil) ⇒ MediaAnalysisResult
Returns a new instance of MediaAnalysisResult.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/turnkit/media_analysis_result.rb', line 11 def initialize(text: "", data: nil, model: nil, provider: nil, usage: Usage.new, params: {}, media: {}, metadata: {}, error: nil, **) @text = text.to_s @data = data @model = model @provider = provider @usage = usage.is_a?(Usage) ? usage : Usage.from_h(usage || {}) @params = params || {} @media = media || {} @metadata = || {} @error = error end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def error @error end |
#media ⇒ Object (readonly)
Returns the value of attribute media.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def media @media end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def @metadata end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def model @model end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def params @params end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def provider @provider end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def text @text end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/turnkit/media_analysis_result.rb', line 5 def usage @usage end |
Class Method Details
.from_h(value) ⇒ Object
7 8 9 |
# File 'lib/turnkit/media_analysis_result.rb', line 7 def self.from_h(value) new(**value.transform_keys(&:to_sym)) end |
Instance Method Details
#cost ⇒ Object
29 30 31 |
# File 'lib/turnkit/media_analysis_result.rb', line 29 def cost Cost.from_usage(usage, model: model) end |
#data? ⇒ Boolean Also known as: structured?
23 24 25 |
# File 'lib/turnkit/media_analysis_result.rb', line 23 def data? !data.nil? end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/turnkit/media_analysis_result.rb', line 33 def to_h { "text" => text, "data" => data, "model" => model, "provider" => provider, "usage" => usage.to_h, "cost" => cost.to_h, "params" => params, "media" => media, "metadata" => , "error" => error }.compact end |