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.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/shul.rb', line 144

def initialize(shoes, source)

  if source.is_a? Rexle then 
    
    doc = source
    
  else
    
    xml, type = RXFHelper.read(source)
    # is the first line an XML processing instruction?
    #jr210517 doc = Rexle.new(xml)
    doc = Shule.new(xml)
    #doc = Rexle.new(xml)
    puts 'doc: ' + doc.xml.inspect
    
  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