class Occi::Core::Renderers::BaseRenderer

Implementes components common to all rendereres. It is not intended for direct use.

@abstract Not for direct use. @author Boris Parak <parak@cesnet.cz>

Public Class Methods

formats() click to toggle source

Returns a list of formats supported by this renderer. Formats are compliant with method naming restrictions and String-like.

@return [Array] list of formats

# File lib/occi/core/renderers/base_renderer.rb, line 24
def formats
  []
end
known() click to toggle source

Returns a frozen Hash providing mapping information between supported types and supported serializers.

@return [Array] list of known type->serializer mappings

# File lib/occi/core/renderers/base_renderer.rb, line 66
def known
  {}
end
known_serializers() click to toggle source

Returns the list of known (and supported) serializer classes. Every element in the list is a fully namespaced classes.

@return [Array] list of known serializers

# File lib/occi/core/renderers/base_renderer.rb, line 58
def known_serializers
  known.values
end
known_types() click to toggle source

Returns the list of known (and supported) types for serialization. Every element in the list is a string representing a fully namespaced class name.

@return [Array] list of known types

# File lib/occi/core/renderers/base_renderer.rb, line 50
def known_types
  known.keys
end
render(object, options) click to toggle source

Renders the given `object` into a rendering in `options`.

@param object [Object] instance to be rendered @param options [Hash] additional rendering options @option options [String] :format (nil) rendering (sub)type @return [String] object rendering

# File lib/occi/core/renderers/base_renderer.rb, line 34
def render(object, options)
  logger.debug "#{self} rendering #{object.inspect} with #{options.inspect}"
  candidate = rendering_candidate(object)
  unless candidate
    raise Occi::Core::Errors::RenderingError, "#{object.class} cannot be "                      "rendered to #{options[:format]}"
  end

  known[candidate].new(object, options).render
end
renderer?() click to toggle source

Indicates whether this class is a renderer candidate.

@return [TrueClass, FalseClass] renderer flag

# File lib/occi/core/renderers/base_renderer.rb, line 15
def renderer?
  false
end