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.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
# File 'lib/shul.rb', line 273

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