Class: InternalRendering

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer, attr_buffer) ⇒ InternalRendering

Returns a new instance of InternalRendering.



126
127
128
# File 'lib/lab.rb', line 126

def initialize buffer, attr_buffer
   @buffer, @attr_buffer = buffer, attr_buffer
end

Instance Attribute Details

#attr_bufferObject

Returns the value of attribute attr_buffer.



125
126
127
# File 'lib/lab.rb', line 125

def attr_buffer
  @attr_buffer
end

#bufferObject

Returns the value of attribute buffer.



125
126
127
# File 'lib/lab.rb', line 125

def buffer
  @buffer
end

Class Method Details

.render_getObject



147
148
149
# File 'lib/lab.rb', line 147

def InternalRendering.render_get
   $myedteststub.to_internal
end

.render_read(id) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/lab.rb', line 150

def InternalRendering.render_read id
   fname = "tests/renderings/rendering-#{id}"
   if ! File.exists? fname
      STDERR.puts "NOTE: writing out #{fname}"
      InternalRendering.render_write id
      return render_get
   end
   str = nil
   File.open(fname) { 
      |file| 
      str = file.gets(nil)
   }
   Marshal.load str
end

.render_write(id) ⇒ Object



164
165
166
# File 'lib/lab.rb', line 164

def InternalRendering.render_write id
   File.open("tests/renderings/rendering-#{id}", "w") { |file| file.puts Marshal.dump(render_get) }
end

.verify_rendering(id) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/lab.rb', line 129

def InternalRendering.verify_rendering id
   a = InternalRendering.render_read id
   b = InternalRendering.render_get
   return true if Marshal.dump(a) == Marshal.dump(b)
   if Marshal.dump(a.attr_buffer) == Marshal.dump(b.attr_buffer)
      puts a.buffer.to_yaml
      puts b.buffer.to_yaml
      return false
   else
      puts "attr:"
      puts a.attr_buffer.to_yaml
      puts a.attr_buffer.to_yaml
      puts "text:"
      puts a.buffer.to_yaml
      puts b.buffer.to_yaml
      return false
   end
end