Class: Trinity::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/trinity/renderer.rb,
lib/trinity/renderer/rdf.rb,
lib/trinity/renderer/html.rb

Instance Attribute Summary

Class Method Summary

Instance Method Summary

Constructor Details

- (Renderer) initialize(env)

A new instance of Renderer



23
24
25
# File 'lib/trinity/renderer.rb', line 23

def initialize(env)
  @env = env
end

Instance Attribute Details

- (Object) env (readonly)

Returns the value of attribute env



20
21
22
# File 'lib/trinity/renderer.rb', line 20

def env
  @env
end

- (Object) resource (readonly)

Returns the value of attribute resource



21
22
23
# File 'lib/trinity/renderer.rb', line 21

def resource
  @resource
end

Class Method Details

+ (Object) content_type(type = nil)



11
12
13
14
15
16
17
18
# File 'lib/trinity/renderer.rb', line 11

def self.content_type(type = nil)
  if type.nil?
    @content_types.first
  else
    @content_types ||= []
    @content_types << type
  end
end

+ (Object) for(env)



7
8
9
# File 'lib/trinity/renderer.rb', line 7

def self.for(env)
  Renderer::RDF # FIXME
end

Instance Method Details

- (Object) content

This method is abstract.

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/trinity/renderer.rb', line 42

def content
  raise NotImplementedError
end

- (Object) headers



32
33
34
# File 'lib/trinity/renderer.rb', line 32

def headers
  {}
end

- (Object) render(resource, options = {})



27
28
29
30
# File 'lib/trinity/renderer.rb', line 27

def render(resource, options = {})
  @resource = resource
  [status, headers, [content]]
end

- (Object) status



36
37
38
# File 'lib/trinity/renderer.rb', line 36

def status
  200 # OK
end