Class: Shul::Window

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shoes, doc) ⇒ Window

Returns a new instance of Window.



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
# File 'lib/shul.rb', line 305

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.



303
304
305
# File 'lib/shul.rb', line 303

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



303
304
305
# File 'lib/shul.rb', line 303

def width
  @width
end

Class Method Details

.element_by_id(id) ⇒ Object



312
313
314
# File 'lib/shul.rb', line 312

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