Class: D3::QuadTree

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

#rootObject



67
68
69
# File 'lib/opal/d3/quadtree.rb', line 67

def root
  D3::Quad.new @native.JS.root
end

#visitObject

visit/visitAfter functions have stupid JS habit of using non-nil return as control and that messes up with languages which have automatic return Maybe worth rewriting to require explicit StopIteration ?



53
54
55
56
57
58
# File 'lib/opal/d3/quadtree.rb', line 53

def visit
  @native.JS.visit(proc do |node, x0, y0, x1, y1|
    yield(D3::Quad.new(node), x0, y0, x1, y1)
  end)
  self
end

#visit_afterObject



60
61
62
63
64
65
# File 'lib/opal/d3/quadtree.rb', line 60

def visit_after
  @native.JS.visitAfter(proc do |node, x0, y0, x1, y1|
    yield(D3::Quad.new(node), x0, y0, x1, y1)
  end)
  self
end

#x(&block) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/opal/d3/quadtree.rb', line 71

def x(&block)
  if block_given?
    @native.JS.x(block)
    self
  else
    @native.JS.x
  end
end

#y(&block) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/opal/d3/quadtree.rb', line 80

def y(&block)
  if block_given?
    @native.JS.y(block)
    self
  else
    @native.JS.y
  end
end