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.



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/domle.rb', line 192

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(RXFReader.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.



190
191
192
# File 'lib/domle.rb', line 190

def event
  @event
end

Instance Method Details

#addevent_listener(event, method_name) ⇒ Object



217
218
219
220
221
# File 'lib/domle.rb', line 217

def addevent_listener(event, method_name)

  @event[event.to_sym] << method_name

end

#element_by_id(id) ⇒ Object



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

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

#elements_by_name(name) ⇒ Object



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

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

#elements_by_tagname(name) ⇒ Object



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

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

#refreshObject



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

def refresh()
  @callback.refresh if @callback and @callback.respond_to? :refresh
end

#refresh_css(node) ⇒ Object



240
241
242
# File 'lib/domle.rb', line 240

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