Class: Occi::Core::Renderers::Text::Model

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

Overview

Implements methods needed to render model instances to text-based renderings. This class (its instances) is usually called directly from the “outside”. It utilizes `Category` from this module to render kinds, actions, and mixins.

Author:

Direct Known Subclasses

Collection

Constant Summary

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`.


28
29
30
31
32
33
34
35
36
# File 'lib/occi/core/renderers/text/model.rb', line 28

def render_headers
  rcats = { Category.category_key_headers => [] }
  object.categories.each do |cat|
    rcats[Category.category_key_headers].concat(
      Category.new(cat, options).render[Category.category_key_headers]
    )
  end
  rcats
end

#render_plainString

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


19
20
21
22
# File 'lib/occi/core/renderers/text/model.rb', line 19

def render_plain
  rcats = object.categories.collect { |cat| Category.new(cat, options).render }
  rcats.join("\n")
end