Class: D3::Quad

Inherits:
Object
  • Object
show all
Includes:
Native
Defined in:
lib/opal/d3/quadtree.rb

Instance Method Summary collapse

Methods included from Native

included, #initialize

Instance Method Details

#childrenObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/opal/d3/quadtree.rb', line 24

def children
  return nil if leaf?
  result = (0..3).map do |i|
    q = `#@native[i]`
    if `q == null`
      nil
    else
      D3::Quad.new(q)
    end
  end
end

#dataObject



19
20
21
22
# File 'lib/opal/d3/quadtree.rb', line 19

def data
  return nil if internal?
  `#@native.data`
end

#internal?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/opal/d3/quadtree.rb', line 5

def internal?
  `#@native.constructor === Array`
end

#leaf?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/opal/d3/quadtree.rb', line 9

def leaf?
  `#@native.constructor !== Array`
end

#nextObject



13
14
15
16
17
# File 'lib/opal/d3/quadtree.rb', line 13

def next
  return nil if internal?
  return nil if `#@native.next == undefined`
  D3::Quad.new(`#@native.next`)
end