Class: Pictify::RenderResult

Inherits:
Object
  • Object
show all
Defined in:
lib/pictify/types.rb

Overview

Result of a template render (render / render_layouts).

The API returns a results[] envelope. The convenience method url returns the URL of the first rendered item, or nil if nothing rendered.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ RenderResult

Returns a new instance of RenderResult.



68
69
70
71
72
73
74
75
76
# File 'lib/pictify/types.rb', line 68

def initialize(data)
  @raw = data
  @results = (data["results"] || []).map { |r| RenderResultItem.new(r) }
  @errors = (data["errors"] || []).map { |e| RenderErrorEntry.new(e) }
  @total_layouts = data["totalLayouts"]
  @total_rendered = data["totalRendered"]
  @total_errors = data["totalErrors"]
  @template_uid = data["templateUid"]
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



65
66
67
# File 'lib/pictify/types.rb', line 65

def errors
  @errors
end

#rawObject (readonly)

Returns the value of attribute raw.



65
66
67
# File 'lib/pictify/types.rb', line 65

def raw
  @raw
end

#resultsObject (readonly)

Returns the value of attribute results.



65
66
67
# File 'lib/pictify/types.rb', line 65

def results
  @results
end

#template_uidObject (readonly)

Returns the value of attribute template_uid.



65
66
67
# File 'lib/pictify/types.rb', line 65

def template_uid
  @template_uid
end

#total_errorsObject (readonly)

Returns the value of attribute total_errors.



65
66
67
# File 'lib/pictify/types.rb', line 65

def total_errors
  @total_errors
end

#total_layoutsObject (readonly)

Returns the value of attribute total_layouts.



65
66
67
# File 'lib/pictify/types.rb', line 65

def total_layouts
  @total_layouts
end

#total_renderedObject (readonly)

Returns the value of attribute total_rendered.



65
66
67
# File 'lib/pictify/types.rb', line 65

def total_rendered
  @total_rendered
end

Instance Method Details

#urlObject

Convenience accessor: URL of the first rendered item (results[0].url).



79
80
81
# File 'lib/pictify/types.rb', line 79

def url
  results.first&.url
end