Class: Footer

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo_developer/app/presenters/footer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#itemsObject (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



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 21

def self.navigation_category_titleize(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


33
34
35
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 33

def self.navigation_link(link)
  link.values.join(' ')
end


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.navigation_link_text(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


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


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

Returns:

  • (Boolean)


76
77
78
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 76

def config_exist?(path)
  File.exist?(path)
end


10
11
12
13
14
15
16
17
18
19
# File 'lib/nexmo_developer/app/presenters/footer.rb', line 10

def footer_from_config(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