Class: D3::Map
Instance Method Summary collapse
-
#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?.
- #entries ⇒ Object
- #get(key) ⇒ Object (also: #[])
- #inspect ⇒ Object
- #to_h ⇒ Object
Methods included from Native
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 |
#entries ⇒ Object
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 |
#inspect ⇒ Object
36 37 38 |
# File 'lib/opal/d3/map.rb', line 36 def inspect "#<D3::Map: #{ to_h.inspect }>" end |
#to_h ⇒ Object
25 26 27 |
# File 'lib/opal/d3/map.rb', line 25 def to_h `Opal.hash(#{entries})` end |