Module: AIA::DynamicContent
Instance Method Summary collapse
- #render_env(a_string) ⇒ Object
-
#render_erb(the_prompt_text) ⇒ Object
Need to use instance variables in assignments to maintain binding from one follow up prompt to another.
Instance Method Details
#render_env(a_string) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/aia/dynamic_content.rb', line 11 def render_env(a_string) a_string.gsub(/\$(\w+|\{\w+\})/) do |match| ENV[match.tr('$', '').tr('{}', '')] end.gsub(/\$\((.*?)\)/) do |match| `#{match[2..-2]}`.chomp end end |
#render_erb(the_prompt_text) ⇒ Object
Need to use instance variables in assignments to maintain binding from one follow up prompt to another.
23 24 25 |
# File 'lib/aia/dynamic_content.rb', line 23 def render_erb(the_prompt_text) ERB.new(the_prompt_text).result(binding) end |