Class: Sidenav
- Inherits:
-
Object
- Object
- Sidenav
- Defined in:
- lib/nexmo_developer/app/presenters/sidenav.rb
Instance Attribute Summary collapse
-
#code_language ⇒ Object
readonly
Returns the value of attribute code_language.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#navigation ⇒ Object
readonly
Returns the value of attribute navigation.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#request_path ⇒ Object
readonly
Returns the value of attribute request_path.
Instance Method Summary collapse
- #documentation? ⇒ Boolean
-
#initialize(request_path:, navigation:, product:, locale: nil, code_language: nil, namespace: nil) ⇒ Sidenav
constructor
rubocop:disable Metrics/ParameterLists.
- #namespace ⇒ Object
-
#nav_items ⇒ Object
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(request_path:, navigation:, product:, locale: nil, code_language: nil, namespace: nil) ⇒ Sidenav
rubocop:disable Metrics/ParameterLists
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 5 def initialize(request_path:, navigation:, product:, locale: nil, code_language: nil, namespace: nil) @request_path = request_path @navigation = @product = product @locale = locale @code_language = code_language @namespace = namespace after_initialize! end |
Instance Attribute Details
#code_language ⇒ Object (readonly)
Returns the value of attribute code_language.
2 3 4 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 2 def code_language @code_language end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
2 3 4 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 2 def locale @locale end |
#navigation ⇒ Object (readonly)
Returns the value of attribute navigation.
2 3 4 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 2 def @navigation end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
2 3 4 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 2 def product @product end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
2 3 4 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 2 def request_path @request_path end |
Instance Method Details
#documentation? ⇒ Boolean
55 56 57 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 55 def documentation? namespace == 'documentation' end |
#namespace ⇒ Object
51 52 53 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 51 def namespace @namespace.presence || 'documentation' end |
#nav_items ⇒ Object
rubocop:enable Metrics/ParameterLists
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 45 46 47 48 49 |
# File 'lib/nexmo_developer/app/presenters/sidenav.rb', line 17 def nav_items @nav_items ||= items.map do |item| if @request_path && @request_path.split('/')[1].include?(item[:title]) SidenavItem.new(folder: item, sidenav: self) end end.compact if @nav_items.blank? @nav_items = items.map do |item| if @product && @product.split('/')[1] && @product.split('/')[1].include?(item[:title]) SidenavItem.new(folder: item, sidenav: self) end end.compact end if @nav_items.blank? @nav_items = items.map do |item| if @product && @product.split('/')[0] && @product.split('/')[0].include?(item[:title]) SidenavItem.new(folder: item, sidenav: self) end end.compact end if @nav_items.blank? @nav_items = items.map do |item| if @product && @product.split('/')[1].nil? && @product.include?(item[:title]) SidenavItem.new(folder: item, sidenav: self) end end.compact end @nav_items end |