Class: Occi::Core::Renderers::Text::Resource
- Includes:
- Instance
- Defined in:
- lib/occi/core/renderers/text/resource.rb
Overview
Implements methods needed to render resource instances to text-based renderings. This class (its instances) is usually called directly from the “outside”. It utilizes ‘Category` and `Attributes` from this module to render kind, mixins, and instance attributes.
Constant Summary collapse
- LINK_KEY =
Link key constant
'Link'.freeze
- LINK_KEY_HEADERS =
'X-OCCI-Link'.freeze
Constants inherited from Base
Base::DELEGATED, Base::RENDER_SAFE
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.action_template ⇒ Object
:nodoc:.
-
.link_template ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#render_headers ⇒ Hash
Renders ‘object` into text for headers and returns the result as `Hash`.
-
#render_plain ⇒ String
Renders ‘object` into plain text and returns the result as `String`.
Methods inherited from Base
#initialize, #render, #render_safe, render_safe
Constructor Details
This class inherits a constructor from Occi::Core::Renderers::Text::Base
Class Method Details
.action_template ⇒ Object
:nodoc:
92 93 94 |
# File 'lib/occi/core/renderers/text/resource.rb', line 92 def action_template '<<%= object.location %>?action=<%= action.term %>>; rel="<%= action %>"' end |
.link_template ⇒ Object
:nodoc:
97 98 99 100 101 102 103 |
# File 'lib/occi/core/renderers/text/resource.rb', line 97 def link_template '<<%= link.target %>>; ' \ 'rel="<%= link.rel %>"; ' \ 'self="<%= link.location %>"; ' \ 'category="<%= link_categories %>"; ' \ '<%= link_attributes %>' end |
Instance Method Details
#render_headers ⇒ Hash
Renders ‘object` into text for headers and returns the result as `Hash`.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/occi/core/renderers/text/resource.rb', line 36 def render_headers headers = short_category(object.kind) headers[Category.category_key_headers].concat( short_mixins_headers ) headers.merge!(instance_attributes) headers.merge!(header_links) headers end |
#render_plain ⇒ String
Renders ‘object` into plain text and returns the result as `String`.
25 26 27 28 29 30 |
# File 'lib/occi/core/renderers/text/resource.rb', line 25 def render_plain [ short_category(object.kind), short_mixins_plain, instance_attributes, instance_links, instance_actions ].flatten.join("\n") end |