class Navigation

Constants

IGNORED_PATHS
OVERRIDES
WEIGHT

Public Class Methods

new(folder) click to toggle source
# File lib/nexmo_developer/app/presenters/navigation.rb, line 7
def initialize(folder)
  @folder = folder
end

Public Instance Methods

document() click to toggle source
# File lib/nexmo_developer/app/presenters/navigation.rb, line 41
def document
  @document ||= path_to_url.sub("#{product}/", '')
end
options() click to toggle source
# File lib/nexmo_developer/app/presenters/navigation.rb, line 11
def options
  @options ||= begin
    path_to_url.tr('/', '.').split('.').inject(OVERRIDES) { |h, k| h[k] || {} }
  end
end
path_to_url() click to toggle source
# File lib/nexmo_developer/app/presenters/navigation.rb, line 17
def path_to_url
  @path_to_url ||= begin
    if @folder[:is_task?]
      path = @folder[:path].sub(@folder[:root], '')
      path.sub(%r{^/\w+/}, '').chomp('.yml')
    else
      path = @folder[:path].gsub("#{Rails.configuration.docs_base_path}/", '')
      path.sub(%r{^\w+/\w+/}, '').chomp('.md')
    end
  end
end
product() click to toggle source
# File lib/nexmo_developer/app/presenters/navigation.rb, line 29
def product
  @product ||= begin
    if @folder[:path].starts_with?('app/views')
      path_to_url.split('/').first
    else
      DocumentationConstraint.products_for_routes.find do |p|
        path_to_url.starts_with? p
      end
    end
  end
end