Class: Shul::Main

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

Instance Method Summary collapse

Constructor Details

#initialize(shoes, source) ⇒ Main

Returns a new instance of Main.



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/shul.rb', line 211

def initialize(shoes, source)

  if source.is_a? Shule then 
    
    doc = source
    
  else
    
    xml, type = RXFHelper.read(source)
    # is the first line an XML processing instruction?

    begin
      doc = Shule.new(xml)
    rescue
      puts 'Shule: something went wrong'
      puts '->' + ($!).inspect
    end
    
  end          
  
  attr = {width: 300, height: 200}.merge doc.root.attributes.to_h      
  
  bflag = if attr.has_key? :width and attr.has_key? :height then
    
    attr[:width] = attr[:width].to_i
    attr[:height] = attr[:height].to_i
    
    false         
  else
    true
  end
  
  shoes.app(attr) do  

    def reload()
      puts 'not yet implemented'
    end
    
    #button 'test' do
    #  alert('fun')
    #end
    
    
    shul = Shul::App.new self, doc, refresh: bflag, \
                                      attributes: {title: 'Shul'}
    Thread.new do
      
      # The following file is generated by Shoes and needs to be 
      # removed to avoid file locks in a thin client server setup.
      
      if File.exists? '/tmp/__green_shoes_temporary_file__' then
        FileUtils.rm '/tmp/__green_shoes_temporary_file__'
      end
      
    end
      
  end
  
end