blob: b6becab4e191600846967aca410ef52f8bf21502 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# sinatra.rb
# Common service
# Author: Andreas Maunz
module OpenTox
class Application < Service
# Conveniently accessible from anywhere within the Application class,
# it negotiates the appropriate output format based on object class
# and requested MIME type.
# @param [Object] an object
# @return [String] object serialization
def format_output (obj)
if obj.class == String
case @accept
when /text\/html/
content_type "text/html"
obj.to_html
else
content_type 'text/uri-list'
obj
end
else
case @accept
when "application/rdf+xml"
content_type "application/rdf+xml"
obj.to_rdfxml
when /text\/html/
content_type "text/html"
obj.to_html
else
content_type "text/turtle"
obj.to_turtle
end
end
end
end
end
|