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.



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/shul.rb', line 296

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