Class: Navigation
- Inherits:
-
Object
- Object
- Navigation
- Defined in:
- lib/nexmo_developer/app/presenters/navigation.rb
Constant Summary collapse
- IGNORED_PATHS =
['..', '.', '.DS_Store'].freeze
- NAVIGATION =
LoadConfig.load_file('config/navigation.yml')
- WEIGHT =
- OVERRIDES =
Instance Method Summary collapse
- #document ⇒ Object
-
#initialize(folder) ⇒ Navigation
constructor
A new instance of Navigation.
- #options ⇒ Object
- #path_to_url ⇒ Object
- #product ⇒ Object
Constructor Details
#initialize(folder) ⇒ Navigation
Returns a new instance of Navigation.
7 8 9 |
# File 'lib/nexmo_developer/app/presenters/navigation.rb', line 7 def initialize(folder) @folder = folder end |
Instance Method Details
#document ⇒ Object
41 42 43 |
# File 'lib/nexmo_developer/app/presenters/navigation.rb', line 41 def document @document ||= path_to_url.sub("#{product}/", '') end |
#options ⇒ Object
11 12 13 14 15 |
# File 'lib/nexmo_developer/app/presenters/navigation.rb', line 11 def @options ||= begin path_to_url.tr('/', '.').split('.').inject(OVERRIDES) { |h, k| h[k] || {} } end end |
#path_to_url ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# 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 ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# 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 |