Class: Footer
- Inherits:
-
Object
- Object
- Footer
- Defined in:
- lib/nexmo_developer/app/presenters/footer.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Class Method Summary collapse
- .navigation_category_titleize(title) ⇒ Object
- .navigation_link(link) ⇒ Object
- .navigation_link_text(link) ⇒ Object
- .support_link(link) ⇒ Object
- .support_link_text(link) ⇒ Object
Instance Method Summary collapse
- #config_exist?(path) ⇒ Boolean
- #footer_from_config(config) ⇒ Object
-
#initialize(items: nil) ⇒ Footer
constructor
A new instance of Footer.
- #open_config(config) ⇒ Object
Constructor Details
#initialize(items: nil) ⇒ Footer
Returns a new instance of Footer.
4 5 6 7 8 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 4 def initialize(items: nil) @items = items after_initialize! end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
2 3 4 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 2 def items @items end |
Class Method Details
.navigation_category_titleize(title) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 21 def self.(title) if title.include?('-') title_split = title.split('-').map do |word| word == 'api' ? word.upcase : word.titleize end title = title_split.join(' ') else title = title.titleize end title end |
.navigation_link(link) ⇒ Object
33 34 35 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 33 def self.(link) link.values.join(' ') end |
.navigation_link_text(link) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 37 def self.(link) text = link.keys.join(' ') if text.include?('-') link_split = text.split('-').map do |word| if word == 'api' word.upcase elsif word == 'apis' 'APIs' elsif word == 'sdk' 'SDK' else word.titleize end end link = link_split.join(' ') elsif text == 'sms' link = text.upcase else link = text.titleize end link end |
.support_link(link) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 60 def self.support_link(link) if link.include?('@') "mailto:#{link}" else link end end |
.support_link_text(link) ⇒ Object
68 69 70 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 68 def self.support_link_text(link) link.titleize end |
Instance Method Details
#config_exist?(path) ⇒ Boolean
76 77 78 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 76 def config_exist?(path) File.exist?(path) end |
#footer_from_config(config) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 10 def (config) config = YAML.safe_load(open_config(config)) { name: config['name'], status: config['footer']['links']['status'], social_links: config['footer']['links']['social'], navigation_links: config['footer']['links']['navigation'], support_links: config['footer']['links']['support'], } end |
#open_config(config) ⇒ Object
72 73 74 |
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 72 def open_config(config) File.open(config) end |