Class: Bijou::Parse::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/bijou/backend.rb

Overview

The base class for the backend code generator. Used to render a component or a piece of a component.

Direct Known Subclasses

Component, Def

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTarget

Returns a new instance of Target.



57
58
59
60
# File 'lib/bijou/backend.rb', line 57

def initialize
  @output = ''
  @args = nil
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



62
63
64
# File 'lib/bijou/backend.rb', line 62

def args
  @args
end

Instance Method Details

#render_args(method, use_markers) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/bijou/backend.rb', line 110

def render_args(method, use_markers)
  result = ''
  if @args
    result << @args.render_args(method, use_markers)
  end
  return result
end

#render_code(code) ⇒ Object

code



95
96
97
# File 'lib/bijou/backend.rb', line 95

def render_code(code) # code
    @output << "#{code}\n"
end

#render_code_(code) ⇒ Object

code



91
92
93
# File 'lib/bijou/backend.rb', line 91

def render_code_(code) # code
    @output << "#{code}"
end

#render_expr(expr) ⇒ Object

print expr



85
86
87
88
89
# File 'lib/bijou/backend.rb', line 85

def render_expr(expr) # print expr
  if expr.length > 0
    @output << "    print #{expr}\n"
  end
end

#render_line(text) ⇒ Object

puts ‘text’



78
79
80
81
82
83
# File 'lib/bijou/backend.rb', line 78

def render_line(text) # puts  'text'
  if text.length > 0
    text = escape_single(text)
    @output << "    puts  '#{text}'\n"
  end
end

#render_marker(line, filename) ⇒ Object

Render a Perl-oriented line marker comment , for use in generating stack traces at runtime. Any line information returned with an Exception object will correspond to the source code that was generated from the component. This line marker comment will allow the runtime to find the corresponding line in the component’s markup text.



106
107
108
# File 'lib/bijou/backend.rb', line 106

def render_marker(line, filename)
  render_code("#line #{line} #{filename}")
end

#render_part(text) ⇒ Object

print ‘text’



71
72
73
74
75
76
# File 'lib/bijou/backend.rb', line 71

def render_part(text) # print 'text'
  if text.length > 0
    text = escape_single(text)
    @output << "    print '#{text}'\n"
  end
end