Class: Head

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

Defined Under Namespace

Classes: Description

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frontmatter = nil) ⇒ Head

Returns a new instance of Head.



21
22
23
24
25
26
# File 'lib/nexmo_developer/app/presenters/head.rb', line 21

def initialize(frontmatter = nil)
  @frontmatter = frontmatter

  after_initialize!
  validate_files_presence!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



19
20
21
# File 'lib/nexmo_developer/app/presenters/head.rb', line 19

def config
  @config
end

#frontmatterObject (readonly)

Returns the value of attribute frontmatter.



19
20
21
# File 'lib/nexmo_developer/app/presenters/head.rb', line 19

def frontmatter
  @frontmatter
end

Instance Method Details

#apple_touch_iconObject



70
71
72
# File 'lib/nexmo_developer/app/presenters/head.rb', line 70

def apple_touch_icon
  'meta/apple-touch-icon.png'
end

#application_nameObject



46
47
48
# File 'lib/nexmo_developer/app/presenters/head.rb', line 46

def application_name
  @application_name ||= config['application-name']
end

#descriptionObject



38
39
40
# File 'lib/nexmo_developer/app/presenters/head.rb', line 38

def description
  @description ||= Description.new(config: config, frontmatter: frontmatter).description
end

#faviconObject



50
51
52
# File 'lib/nexmo_developer/app/presenters/head.rb', line 50

def favicon
  'meta/favicon.ico'
end

#favicon_32_squaredObject



54
55
56
# File 'lib/nexmo_developer/app/presenters/head.rb', line 54

def favicon_32_squared
  'meta/favicon-32x32.png'
end

#google_site_verificationObject



42
43
44
# File 'lib/nexmo_developer/app/presenters/head.rb', line 42

def google_site_verification
  @google_site_verification ||= config['google-site-verification']
end

#manifestObject



58
59
60
# File 'lib/nexmo_developer/app/presenters/head.rb', line 58

def manifest
  'meta/manifest.json'
end

#mstile_144_squaredObject



66
67
68
# File 'lib/nexmo_developer/app/presenters/head.rb', line 66

def mstile_144_squared
  'meta/mstile-144x144.png'
end

#og_imageObject



74
75
76
# File 'lib/nexmo_developer/app/presenters/head.rb', line 74

def og_image
  @og_image ||= "meta/#{config['og-image']}"
end

#og_image_heightObject



82
83
84
# File 'lib/nexmo_developer/app/presenters/head.rb', line 82

def og_image_height
  @og_image_height ||= config['og-image-height']
end

#og_image_widthObject



78
79
80
# File 'lib/nexmo_developer/app/presenters/head.rb', line 78

def og_image_width
  @og_image_width ||= config['og-image-width']
end

#safari_pinned_tabObject



62
63
64
# File 'lib/nexmo_developer/app/presenters/head.rb', line 62

def safari_pinned_tab
  'meta/safari-pinned-tab.svg'
end

#titleObject



28
29
30
31
32
# File 'lib/nexmo_developer/app/presenters/head.rb', line 28

def title
  @title ||= title_from_frontmatter || config.fetch('title') do
    raise "You must provide a 'title' parameter in header_meta.yml"
  end
end

#title_from_frontmatterObject



34
35
36
# File 'lib/nexmo_developer/app/presenters/head.rb', line 34

def title_from_frontmatter
  @frontmatter && (@frontmatter['meta_title'] || @frontmatter['title'])
end