Class: Occi::Core::Renderers::Text::Locations
- Defined in:
- lib/occi/core/renderers/text/locations.rb
Overview
Implements routines required to render ‘Occi::Core::Locations` and its subclasses to a text-based representation. Supports rendering to plain and header-like formats.
Constant Summary collapse
- LOCATION_KEY_PLAIN =
Location key constants
'X-OCCI-Location'.freeze
- LOCATION_KEY_HEADERS =
'Location'.freeze
Constants inherited from Base
Base::DELEGATED, Base::RENDER_SAFE
Instance Attribute Summary
Attributes inherited from Base
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
Instance Method Details
#render_headers ⇒ Hash
Renders ‘object` into text for headers and returns the result as `Hash`.
30 31 32 33 |
# File 'lib/occi/core/renderers/text/locations.rb', line 30 def render_headers return {} if object.empty? { LOCATION_KEY_HEADERS => location_ary_or_first } end |
#render_plain ⇒ String
Renders ‘object` into plain text and returns the result as `String`.
21 22 23 24 |
# File 'lib/occi/core/renderers/text/locations.rb', line 21 def render_plain locs = object.map { |loc| "#{LOCATION_KEY_PLAIN}: #{loc}" } locs.join "\n" end |