Class: Nexmo::Markdown::Filters::CodeSnippet::CreateApplication
- Inherits:
-
Object
- Object
- Nexmo::Markdown::Filters::CodeSnippet::CreateApplication
show all
- Includes:
- Renderable
- Defined in:
- lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb
Constant Summary
collapse
- NGROK_URL =
'http://demo.ngrok.io'.freeze
- EXAMPLE_URL =
'https://example.com'.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Renderable
#client_url, #id, #normalized_language, #renderer
Constructor Details
Returns a new instance of CreateApplication.
13
14
15
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 13
def initialize(app)
@app = app
end
|
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
11
12
13
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 11
def app
@app
end
|
Instance Method Details
#answer_url ⇒ Object
35
36
37
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 35
def answer_url
@answer_url ||= @app.fetch('answer_url', "#{base_url}/webhooks/answer")
end
|
#base_url ⇒ Object
17
18
19
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 17
def base_url
@base_url ||= @app['disable_ngrok'] && EXAMPLE_URL || NGROK_URL
end
|
#event_url ⇒ Object
31
32
33
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 31
def event_url
@event_url ||= @app.fetch('event_url', "#{base_url}/webhooks/events")
end
|
#name ⇒ Object
21
22
23
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 21
def name
@name ||= @app['name'] || 'ExampleProject'
end
|
#partial ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 39
def partial
@partial ||= begin
case type
when 'voice', 'rtc'
File.read("#{GEM_ROOT}/lib/nexmo_markdown_renderer/views/code_snippets/_application_#{type}.html.erb")
when 'messages', 'dispatch'
File.read("#{GEM_ROOT}/lib/nexmo_markdown_renderer/views/code_snippets/_application_messages_dispatch.html.erb")
else
raise "Invalid application type when creating code snippet: '#{type}'"
end
end
end
|
#render ⇒ Object
52
53
54
55
56
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 52
def render
return '' unless @app
ERB.new(partial).result(binding)
end
|
#type ⇒ Object
25
26
27
28
29
|
# File 'lib/nexmo_markdown_renderer/filters/code_snippet/create_application.rb', line 25
def type
@type ||= @app.fetch('type', 'voice')
end
|