Class: Shul::Window

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

Defined Under Namespace

Classes: Radiogroup

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shoes, doc) ⇒ Window

Returns a new instance of Window.



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/shul.rb', line 407

def initialize(shoes, doc)
  
  @shoes = shoes
  @width, @height = 100, 100
  
  @doc = doc
  
  def @doc.element_by_id(id)
    self.root.element("//*[@id='#{id}']")
  end      

  @doc.root.elements.each do |x| 
    method(x.name.sub(':','_').to_sym).call(x) unless x.name == 'script'
  end   
  
  @doc.root.xpath('script').each {|x| script x }
  
  h = @doc.root.attributes
  
  if h[:onkeypress] then
    shoes.keypress do |k| 
      method(h[:onkeypress][/^[a-z]\w+/].to_sym).call(k)
    end
  end

end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



405
406
407
# File 'lib/shul.rb', line 405

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



405
406
407
# File 'lib/shul.rb', line 405

def width
  @width
end

Class Method Details

.element_by_id(id) ⇒ Object



414
415
416
# File 'lib/shul.rb', line 414

def @doc.element_by_id(id)
  self.root.element("//*[@id='#{id}']")
end

Instance Method Details

#add_element(node) ⇒ Object



434
435
436
437
438
439
# File 'lib/shul.rb', line 434

def add_element(node)

  node.obj = method(node.name.sub(':','_').to_sym).call(node)            
  refresh()

end

#refreshObject



441
442
443
# File 'lib/shul.rb', line 441

def refresh
  @shoes.flush if @shoes
end

#remove_element(node) ⇒ Object



445
446
447
448
# File 'lib/shul.rb', line 445

def remove_element(node)
  node.obj.clear
  refresh()
end