Class: Nexmo::Markdown::Filters::CodeSnippet::InstallDependencies

Inherits:
Object
  • Object
show all
Includes:
Renderable
Defined in:
lib/nexmo_markdown_renderer/filters/code_snippet/install_dependencies.rb

Instance Method Summary collapse

Methods included from Renderable

#client_url, #id, #normalized_language, #renderer

Constructor Details

#initialize(config, version, snippet) ⇒ InstallDependencies

Returns a new instance of InstallDependencies.



8
9
10
11
12
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/install_dependencies.rb', line 8

def initialize(config, version, snippet)
  @config  = config
  @snippet = snippet
  @version = version
end

Instance Method Details

#partialObject



14
15
16
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/install_dependencies.rb', line 14

def partial
  @partial ||= File.read("#{GEM_ROOT}/lib/nexmo_markdown_renderer/views/code_snippets/_dependencies.html.erb")
end

#renderObject



29
30
31
32
33
34
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/install_dependencies.rb', line 29

def render
  return '' unless @config

  deps = renderer.dependencies(@config, @version)
  ERB.new(partial).result(binding)
end

#titleObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/install_dependencies.rb', line 18

def title
  @title ||= begin
    # The only valid dependency for curl examples is `JWT`
    if @config.map(&:upcase).include?('JWT')
      ::I18n.t('filters.generate_your_jwt')
    else
      ::I18n.t('filters.install_dependencies')
    end
  end
end