Class: D3::Map

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

Instance Method Summary collapse

Methods included from Native

included, #initialize

Instance Method Details

#each(&block) ⇒ Object

Should that be reversed to better match ruby and to work with Enumerable? Or just use #to_h if you want ruby interface?



31
32
33
34
# File 'lib/opal/d3/map.rb', line 31

def each(&block)
  @native.JS.each(block)
  self
end

#entriesObject



21
22
23
# File 'lib/opal/d3/map.rb', line 21

def entries
  @native.JS.entries().map{|o| [`o.key`, `o.value`]}
end

#get(key) ⇒ Object Also known as: []



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

def get(key)
  result = @native.JS.get(key)
  `result === undefined ? nil : result`
end

#inspectObject



36
37
38
# File 'lib/opal/d3/map.rb', line 36

def inspect
  "#<D3::Map: #{ to_h.inspect }>"
end

#to_hObject



25
26
27
# File 'lib/opal/d3/map.rb', line 25

def to_h
  `Opal.hash(#{entries})`
end