Class: Domle

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

Defined Under Namespace

Classes: Element, Script, Style

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src = '<svg/>', callback: nil, rexle: nil, debug: false) ⇒ Domle

Returns a new instance of Domle.



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/domle.rb', line 188

def initialize(src='<svg/>', callback: nil, rexle: nil, debug: false)

  @callback, @debug, @rexle = callback, debug, rexle
  puts 'inside Domle initialize'.info if @debug
  puts 'src:' + src.inspect if @debug
  
  super(RXFHelper.read(src).first, rexle: self)
  @debug = debug
  
  puts 'before find add_css' if @debug
  find_add_css() if src

  
  @event = {
    keydown: [],
    keyup: [],
    mousemove: [],
    mousedown: [],
    mouseenter: [],
    mouseleave: [],
    scroll: []
  }
  
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



186
187
188
# File 'lib/domle.rb', line 186

def event
  @event
end

Instance Method Details

#addevent_listener(event, method_name) ⇒ Object



213
214
215
216
217
# File 'lib/domle.rb', line 213

def addevent_listener(event, method_name)
      
  @event[event.to_sym] << method_name
  
end

#element_by_id(id) ⇒ Object



220
221
222
# File 'lib/domle.rb', line 220

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

#elements_by_name(name) ⇒ Object



224
225
226
# File 'lib/domle.rb', line 224

def elements_by_name(name)
  @doc.root.xpath("//*[@name='#{name}']")
end

#elements_by_tagname(name) ⇒ Object



228
229
230
# File 'lib/domle.rb', line 228

def elements_by_tagname(name)
  @doc.root.xpath("//#{name}")
end

#refreshObject



232
233
234
# File 'lib/domle.rb', line 232

def refresh()
  @callback.refresh if @callback
end

#refresh_css(node) ⇒ Object



236
237
238
# File 'lib/domle.rb', line 236

def refresh_css(node)
  find_add_css(node.parent)
end