Class: Nexmo::Markdown::Filters::CodeSnippet::ImportDependencies

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renderable

#client_url, #id, #normalized_language, #renderer

Constructor Details

#initialize(config, snippet) ⇒ ImportDependencies

Returns a new instance of ImportDependencies.



10
11
12
13
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/import_dependencies.rb', line 10

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/import_dependencies.rb', line 8

def config
  @config
end

Instance Method Details

#highlighted_import_sourceObject



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

def highlighted_import_source
  @highlighted_import_source ||= ::Nexmo::Markdown::Utils.generate_code_block(
    language,
    @config,
    unindent,
    renderer
  )
end

#partialObject



15
16
17
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/import_dependencies.rb', line 15

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

#renderObject



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

def render
  return '' unless @config

  create_instructions = renderer.create_instructions(file_name).render_markdown
  ERB.new(partial).result(binding)
end