Class: CERB
- Inherits:
-
Object
- Object
- CERB
- Defined in:
- lib/csquare/cerb.rb
Defined Under Namespace
Classes: Buffer
Constant Summary collapse
- SPLIT_REGEXP =
/^\s*#\s*RUBY\s+/
Instance Attribute Summary collapse
-
#blueprint ⇒ Object
readonly
Returns the value of attribute blueprint.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
-
#initialize(file, blueprint) ⇒ CERB
constructor
A new instance of CERB.
Constructor Details
#initialize(file, blueprint) ⇒ CERB
Returns a new instance of CERB.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/csquare/cerb.rb', line 22 def initialize file, blueprint @blueprint = blueprint out = Buffer.new eval_str = nil @src = [] while line = file.gets line.chomp! c_code, eval_str = line.split(SPLIT_REGEXP, 2) #binding.pry if line == "#RUBY if blueprint.id != :complex" if eval_str.nil? out.push c_code else unless out.empty? @src << "puts #{out.result.dump}" out.reset! end @src << "puts ''" # empty line in place of #RUBY statements (ensures line numbers match source files in debugging) @src << eval_str end end @src << "puts #{out.result.dump}" if eval_str.nil? && !out.empty? @src << "puts ''" # prevent EOF errors #binding.pry eval @src.join("\n") end |
Instance Attribute Details
#blueprint ⇒ Object (readonly)
Returns the value of attribute blueprint.
56 57 58 |
# File 'lib/csquare/cerb.rb', line 56 def blueprint @blueprint end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
56 57 58 |
# File 'lib/csquare/cerb.rb', line 56 def src @src end |