class Fdoc::ServicePresenter

An BasePresenter for Fdoc::Service

Attributes

service[R]

Public Class Methods

new(service, options = {}) click to toggle source
Calls superclass method Fdoc::BasePresenter::new
# File lib/fdoc/presenters/service_presenter.rb, line 10
def initialize(service, options = {})
  super(options)
  @service = service
end

Public Instance Methods

description(options = {:render => true}) click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 58
def description(options = {:render => true})
  options[:render] ? render_markdown(service.description) : service.description
end
discussion(options = {:render => true}) click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 62
def discussion(options = {:render => true})
  options[:render] ? render_markdown(service.discussion) : service.discussion
end
endpoints() click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 36
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
relative_meta_service_path(file_name = nil) click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 66
def relative_meta_service_path(file_name = nil)
  service_path = service_dir.gsub(meta_service.meta_service_dir, "")
  service_path = service_path.count("/").times.map { "../" }.join
  if file_name
    service_path = File.join(service_path, file_name)
  end
  service_path
end
slug_name() click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 28
def slug_name
  service.name.downcase.gsub(/[ \/]/, '_')
end
to_html() click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 15
def to_html
  render_erb('service.html.erb')
end
to_markdown() click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 19
def to_markdown
  render_erb('service.md.erb')
end
url(extension = ".html") click to toggle source
# File lib/fdoc/presenters/service_presenter.rb, line 32
def url(extension = ".html")
  '%s-%s%s' % [ @endpoint.path, @endpoint.verb, extension ]
end