Class: Occi::Core::Renderers::Text::Attributes

Inherits:
Base
  • Object
show all
Defined in:
lib/occi/core/renderers/text/attributes.rb

Overview

Implements methods needed to render instance attributes to text-based renderings. This class (its instances) is usually called directly from other classes in this module and not from the “outside”.

Author:

Constant Summary collapse

ATTRIBUTE_KEY =

Attribute key constant

'X-OCCI-Attribute'.freeze
PRIMITIVE_TYPES =

Known primitive attribute value types

[String, Numeric, Integer, Float, Boolean].freeze
IP_TYPES =
[IPAddr].freeze
QUOTABLE_TYPES =
[URI].freeze
JSONABLE_TYPES =
[Array, Hash].freeze

Constants inherited from Base

Base::DELEGATED, Base::RENDER_SAFE

Instance Attribute Summary

Attributes inherited from Base

#object, #options

Instance Method Summary collapse

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_headersHash

Renders `object` into text for headers and returns the result as `Hash`.


34
35
36
# File 'lib/occi/core/renderers/text/attributes.rb', line 34

def render_headers
  { ATTRIBUTE_KEY => prepare_instance_attributes }
end

#render_plainString

Renders `object` into plain text and returns the result as `String`.


26
27
28
# File 'lib/occi/core/renderers/text/attributes.rb', line 26

def render_plain
  prepare_instance_attributes.collect { |attrb| "#{ATTRIBUTE_KEY}: #{attrb}" }.join("\n")
end