numo-gnuplot 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/numo/gnuplot.rb +69 -42
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e87eaed8bca276f54c5fe06d2e009ceeb3a5355a
|
4
|
+
data.tar.gz: 6f26b92d3cb90a633703b4392dbd0adb60ff070b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c6aaed522a0cdd5386afc91a40f26c3d51030d5aa31b3f9f3e535febf0abd6895aea67be8bdede43774ffae97d8b4f7590b93098b12854de12b4bb0b8a5b0b8
|
7
|
+
data.tar.gz: e6d06e0c9b00554eb7194b5284ea2c2c5f960810a2dfb3a652e6006028c95ea88f57f1b2ffd50688465cd1a1ce1517dcc308f0fc3416d219879825b31d8cc04b
|
data/lib/numo/gnuplot.rb
CHANGED
@@ -16,7 +16,7 @@ module Numo
|
|
16
16
|
|
17
17
|
class Gnuplot
|
18
18
|
|
19
|
-
VERSION = "0.1.
|
19
|
+
VERSION = "0.1.7"
|
20
20
|
POOL = []
|
21
21
|
DATA_FORMAT = "%.7g"
|
22
22
|
|
@@ -116,7 +116,7 @@ class Gnuplot
|
|
116
116
|
case a
|
117
117
|
when Hash
|
118
118
|
a.each do |k,v|
|
119
|
-
run "#{cmd} #{
|
119
|
+
run "#{cmd} #{OptArg.parse_kv(k,v)}"
|
120
120
|
end
|
121
121
|
else
|
122
122
|
run "#{cmd} #{a}"
|
@@ -150,7 +150,7 @@ class Gnuplot
|
|
150
150
|
# pause 'mouse'
|
151
151
|
# pause mouse:%w[keypress button1 button2 button3 close any]
|
152
152
|
def pause(*args)
|
153
|
-
send_cmd("pause #{
|
153
|
+
send_cmd("pause #{OptArg.parse(*args)}").join.chomp
|
154
154
|
nil
|
155
155
|
end
|
156
156
|
|
@@ -264,6 +264,8 @@ class Gnuplot
|
|
264
264
|
"gnuplot"
|
265
265
|
end
|
266
266
|
|
267
|
+
# private methods
|
268
|
+
|
267
269
|
def run(s,data=nil)
|
268
270
|
res = send_cmd(s,data)
|
269
271
|
if !res.empty?
|
@@ -327,25 +329,19 @@ class Gnuplot
|
|
327
329
|
|
328
330
|
|
329
331
|
# @private
|
330
|
-
|
331
|
-
def initialize(*opts)
|
332
|
-
@opts = opts
|
333
|
-
end
|
332
|
+
module OptArg # :nodoc: all
|
334
333
|
|
335
|
-
|
336
|
-
opts_to_s(*@opts)
|
337
|
-
end
|
334
|
+
module_function
|
338
335
|
|
339
|
-
def
|
340
|
-
#p opts
|
336
|
+
def parse(*opts)
|
341
337
|
sep = ","
|
342
338
|
opts.map do |opt|
|
343
339
|
sep = " " if !opt.kind_of?(Numeric)
|
344
340
|
case opt
|
345
341
|
when Array
|
346
|
-
opt.map{|v| "#{
|
342
|
+
opt.map{|v| "#{parse(*v)}"}.join(sep)
|
347
343
|
when Hash
|
348
|
-
opt.map{|k,v|
|
344
|
+
opt.map{|k,v| parse_kv(k,v)}.compact.join(" ")
|
349
345
|
when Range
|
350
346
|
"[#{opt.begin}:#{opt.end}]"
|
351
347
|
else
|
@@ -353,17 +349,17 @@ class Gnuplot
|
|
353
349
|
end
|
354
350
|
end.join(sep)
|
355
351
|
end
|
356
|
-
end
|
357
352
|
|
358
|
-
# @private
|
359
|
-
class KvItem # :nodoc: all
|
360
353
|
NEED_QUOTE = %w[
|
361
354
|
background
|
362
355
|
cblabel
|
363
356
|
clabel
|
357
|
+
commentschars
|
364
358
|
dashtype
|
359
|
+
decimalsign
|
365
360
|
dt
|
366
361
|
font
|
362
|
+
fontpath
|
367
363
|
format
|
368
364
|
format_cb
|
369
365
|
format_x
|
@@ -372,8 +368,14 @@ class Gnuplot
|
|
372
368
|
format_y
|
373
369
|
format_y2
|
374
370
|
format_z
|
371
|
+
locale
|
372
|
+
logfile
|
373
|
+
missing
|
375
374
|
output
|
375
|
+
print
|
376
376
|
rgb
|
377
|
+
separator
|
378
|
+
table
|
377
379
|
timefmt
|
378
380
|
title
|
379
381
|
x2label
|
@@ -381,30 +383,54 @@ class Gnuplot
|
|
381
383
|
y2label
|
382
384
|
ylabel
|
383
385
|
zlabel
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
386
|
+
cb
|
387
|
+
x
|
388
|
+
xy
|
389
|
+
x2
|
390
|
+
y
|
391
|
+
y2
|
392
|
+
z
|
393
|
+
]
|
394
|
+
|
395
|
+
def NEED_QUOTE.===(k)
|
396
|
+
re = /^#{k}/
|
397
|
+
any?{|q| re =~ q}
|
398
|
+
end
|
399
|
+
|
400
|
+
def parse_kv(k,v)
|
401
|
+
case k.to_sym
|
402
|
+
when :at
|
403
|
+
case v
|
404
|
+
when String
|
405
|
+
"#{k} #{v}" # not quote
|
406
|
+
when Array
|
407
|
+
"#{k} #{v.map{|x|(x.kind_of? String) ? x.inspect : x.to_s}.join(",")}"
|
408
|
+
else
|
409
|
+
"#{k} #{parse(v)}"
|
410
|
+
end
|
411
|
+
when :label
|
403
412
|
case v
|
404
413
|
when String
|
405
414
|
"#{k} #{v.inspect}"
|
406
415
|
when Array
|
407
|
-
|
416
|
+
if v[0].kind_of?(Integer) && v[1].kind_of?(String)
|
417
|
+
"#{k} #{parse(v[0],v[1].inspect,*v[2..-1])}"
|
418
|
+
elsif v[0].kind_of?(String)
|
419
|
+
"#{k} #{parse(v[0].inspect,*v[1..-1])}"
|
420
|
+
else
|
421
|
+
"#{k} #{parse(*v)}"
|
422
|
+
end
|
423
|
+
else
|
424
|
+
"#{k} #{parse(v)}"
|
425
|
+
end
|
426
|
+
when NEED_QUOTE
|
427
|
+
case v
|
428
|
+
when String
|
429
|
+
"#{k.to_s.sub(/_/,' ')} #{v.inspect}"
|
430
|
+
when Array
|
431
|
+
"#{k} #{v[0].inspect} #{parse(*v[1..-1])}"
|
432
|
+
else
|
433
|
+
"#{k} #{parse(v)}"
|
408
434
|
end
|
409
435
|
else
|
410
436
|
case v
|
@@ -420,14 +446,15 @@ class Gnuplot
|
|
420
446
|
if /^#{k}/ =~ "using"
|
421
447
|
"#{k} #{v.join(':')}"
|
422
448
|
else
|
423
|
-
"#{k} #{
|
449
|
+
"#{k} #{parse(*v)}"
|
424
450
|
end
|
425
451
|
else
|
426
|
-
"#{k} #{
|
452
|
+
"#{k} #{parse(v)}"
|
427
453
|
end
|
428
454
|
end
|
429
455
|
end
|
430
|
-
|
456
|
+
|
457
|
+
end # OptArg
|
431
458
|
|
432
459
|
|
433
460
|
# @private
|
@@ -499,9 +526,9 @@ class Gnuplot
|
|
499
526
|
def cmd_str
|
500
527
|
parse_items
|
501
528
|
if @function
|
502
|
-
"%s %s" % [@function,
|
529
|
+
"%s %s" % [@function, OptArg.parse(*@options)]
|
503
530
|
else
|
504
|
-
"%s %s" % [@data.cmd_str,
|
531
|
+
"%s %s" % [@data.cmd_str, OptArg.parse(*@options)]
|
505
532
|
end
|
506
533
|
end
|
507
534
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numo-gnuplot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro TANAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,9 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.6.8
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Gnuplot interface for Ruby.
|
89
89
|
test_files: []
|
90
|
-
has_rdoc:
|