Class: D3::DsvFormat

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

Instance Method Summary collapse

Methods included from Native

included, #initialize

Instance Method Details

#parse(string, row = `undefined`, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/opal/d3/dsv.rb', line 17

def parse(string, row=`undefined`, &block)
  row = block if block_given?
  if `row !== undefined`
    @native.JS.parse(string, proc{|e|
      result = row.call(`Opal.hash(e)`)
      result == nil ? `null` : result
    })
  else
    @native.JS.parse(string).map{|e| `Opal.hash(e)` }
  end
end

#parse_rows(string, row = `undefined`, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/opal/d3/dsv.rb', line 5

def parse_rows(string, row=`undefined`, &block)
  row = block if block_given?
  if `row !== undefined`
    @native.JS.parseRows(string, proc{|d|
      result = row.call(d)
      result == nil ? `null` : result
    })
  else
    @native.JS.parseRows(string)
  end
end