Class: Nexmo::Markdown::Filters::CodeSnippet::Instructions
- Inherits:
-
Object
- Object
- Nexmo::Markdown::Filters::CodeSnippet::Instructions
show all
- Includes:
- Renderable
- Defined in:
- lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Renderable
#client_url, #id, #normalized_language, #renderer
Constructor Details
#initialize(config, snippet) ⇒ Instructions
Returns a new instance of Instructions.
10
11
12
13
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb', line 10
def initialize(config, snippet)
@config = config
@snippet = snippet
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8
9
10
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb', line 8
def config
@config
end
|
Instance Method Details
#highlighted_code_source ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb', line 25
def highlighted_code_source
@highlighted_code_source ||= ::Nexmo::Markdown::Utils.generate_code_block(
language,
@config['code'],
unindent,
renderer
)
end
|
#partial ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb', line 15
def partial
@partial ||= begin
if @config['code_only']
File.read("#{GEM_ROOT}/lib/nexmo_markdown_renderer/views/code_snippets/_code_only.html.erb")
else
File.read("#{GEM_ROOT}/lib/nexmo_markdown_renderer/views/code_snippets/_write_code.html.erb")
end
end
end
|
#render ⇒ Object
38
39
40
41
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb', line 38
def render
add_instructions = renderer.add_instructions(file_name).render_markdown
ERB.new(partial).result(binding)
end
|
#source_url ⇒ Object
34
35
36
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/instructions.rb', line 34
def source_url
@source_url ||= ::Nexmo::Markdown::Utils.generate_source_url(@config['code'])
end
|