Class: Fdoc::ServicePresenter
Overview
An HtmlPresenter for Fdoc::Service
Instance Attribute Summary collapse
#options
Instance Method Summary
collapse
#css_path, #html_directory, #index_path, #render_erb, #render_json, #render_markdown, #tag_with_anchor
Constructor Details
#initialize(service, options = {}) ⇒ ServicePresenter
Returns a new instance of ServicePresenter.
5
6
7
8
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 5
def initialize(service, options = {})
super(options)
@service = service
end
|
Instance Attribute Details
#service ⇒ Object
Returns the value of attribute service.
3
4
5
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 3
def service
@service
end
|
Instance Method Details
#description ⇒ Object
49
50
51
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 49
def description
render_markdown(service.description)
end
|
#discussion ⇒ Object
53
54
55
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 53
def discussion
render_markdown(service.discussion)
end
|
#endpoints ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 27
def endpoints
if !@endpoints
@endpoints = []
prefix = nil
service.endpoints.sort_by(&:endpoint_path).each do |endpoint|
presenter = Fdoc::EndpointPresenter.new(endpoint, options)
presenter.service_presenter = self
presenter
current_prefix = presenter.prefix
@endpoints << [] if prefix != current_prefix
@endpoints.last << presenter
prefix = current_prefix
end
end
@endpoints
end
|
#name_as_link(options = {}) ⇒ Object
14
15
16
17
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 14
def name_as_link(options = {})
path = service.meta_service ? index_path(slug_name) : index_path
'<a href="%s">%s %s</a>' % [ path, options[:prefix], service.name ]
end
|
#slug_name ⇒ Object
19
20
21
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 19
def slug_name
service.name.downcase.gsub(/[ \/]/, '_')
end
|
#to_html ⇒ Object
10
11
12
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 10
def to_html
render_erb('service.html.erb')
end
|
#url(extension = ".html") ⇒ Object
23
24
25
|
# File 'lib/fdoc/presenters/service_presenter.rb', line 23
def url(extension = ".html")
'%s-%s%s' % [ @endpoint.path, @endpoint.verb, extension ]
end
|