Class: VER::Snippet
- Inherits:
-
Object
- Object
- VER::Snippet
- Defined in:
- lib/ver/methods/snippet.rb
Overview
TODO: transformations
Constant Summary collapse
- LITERAL_BACKTICK =
/\\`/
- LITERAL_DOLLAR =
/\\\$/
- LITERAL_BACKSLASH =
/\\/
- PLAIN_TEXT =
/[^\\`$]+/
- TAB_STOP =
/\$(\d+)/
- NESTED_TAB_STOP =
/^\$\{(?<id>\d+):(?<nested>((?<pg>\$\{(?:\\\$\{|\\\}|[^\\}$]|\g<pg>)*\})|(?:\\\}|\\\$\{|[^$}]))+)\}/
- SUBSTITUTE_VARIABLE =
/\$(#{variable})/
- SUBSTITUTE_VARIABLE_WITH_DEFAULT =
/\$\{(#{variable}):([^}]+)\}/
- SUBSTITUTE_VARIABLE_WITH_REGEXP =
/\$\{(#{variable})\/(#{regexp})\/(#{format})\/(#{})\}/
- SUBSTITUTE_SHELL_CODE =
/`((?:\\`|[^`\\]+)*)`/
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
Instance Method Summary collapse
- #apply_on(buffer) ⇒ Object
-
#initialize(snippet, env = {}) ⇒ Snippet
constructor
A new instance of Snippet.
- #result ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(snippet, env = {}) ⇒ Snippet
Returns a new instance of Snippet.
160 161 162 163 |
# File 'lib/ver/methods/snippet.rb', line 160 def initialize(snippet, env = {}) @snippet = snippet @env = env end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
158 159 160 |
# File 'lib/ver/methods/snippet.rb', line 158 def env @env end |
Instance Method Details
#apply_on(buffer) ⇒ Object
175 176 177 178 |
# File 'lib/ver/methods/snippet.rb', line 175 def apply_on(buffer) parse(@snippet, out = []) apply_out_on(buffer, out) end |
#result ⇒ Object
170 171 172 173 |
# File 'lib/ver/methods/snippet.rb', line 170 def result parse(@snippet, out = []) out end |
#to_s ⇒ Object
165 166 167 168 |
# File 'lib/ver/methods/snippet.rb', line 165 def to_s parse(@snippet, out = []) out.join end |