Class: PHPRB::Compiler::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/web/phprb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler) ⇒ Buffer

Returns a new instance of Buffer.



99
100
101
102
103
104
105
106
# File 'lib/web/phprb.rb', line 99

def initialize(compiler)
  @compiler = compiler
  @line = []
  @script = ""
  @compiler.pre_cmd.each do |x|
    push(x)
  end
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



107
108
109
# File 'lib/web/phprb.rb', line 107

def script
  @script
end

Instance Method Details

#closeObject



119
120
121
122
123
124
125
126
# File 'lib/web/phprb.rb', line 119

def close
  return unless @line
  @compiler.post_cmd.each do |x|
    push(x)
  end
  @script << (@line.join('; '))
  @line = nil
end

#crObject



113
114
115
116
117
# File 'lib/web/phprb.rb', line 113

def cr
  @script << (@line.join('; '))
  @line = []
  @script << "\n"
end

#push(cmd) ⇒ Object



109
110
111
# File 'lib/web/phprb.rb', line 109

def push(cmd)
  @line << cmd
end