Class: Cubism::Preprocessor
- Inherits:
-
Object
- Object
- Cubism::Preprocessor
- Defined in:
- lib/cubism/preprocessor.rb
Instance Attribute Summary collapse
-
#block_variable_name ⇒ Object
readonly
Returns the value of attribute block_variable_name.
Instance Method Summary collapse
-
#initialize(source:, view_context:) ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #process ⇒ Object
Constructor Details
#initialize(source:, view_context:) ⇒ Preprocessor
Returns a new instance of Preprocessor.
5 6 7 8 9 10 11 |
# File 'lib/cubism/preprocessor.rb', line 5 def initialize(source:, view_context:) match_data = /<%=\s+cubicle_for.+?\|(\w+)\|\s+%>/.match(source) start_pos = match_data&.end(0) || 0 @block_variable_name = match_data[1] if match_data @source = source[start_pos..] @view_context = view_context end |
Instance Attribute Details
#block_variable_name ⇒ Object (readonly)
Returns the value of attribute block_variable_name.
3 4 5 |
# File 'lib/cubism/preprocessor.rb', line 3 def block_variable_name @block_variable_name end |
Instance Method Details
#process ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cubism/preprocessor.rb', line 13 def process begin do_parse rescue NameError # TODO we need a better way to handle this, leads to false negatives # we ignore any name errors from unset instance variables or local assigns here end @source end |