gmt 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gmt/gmt.c +4 -3
  3. data/lib/gmt.rb +71 -11
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1348e925157b856022bda1c2f6c83a848be3972
4
- data.tar.gz: f935f6dab2efd89e6129b9846596adc72373fa06
3
+ metadata.gz: 4691c0f699ea4423dd732be0e007565dac9fde44
4
+ data.tar.gz: f122cc4a4c66faeaa08aa461cc9dc032b010c1cc
5
5
  SHA512:
6
- metadata.gz: bec6cdaf7e5fe4e47435154e10e3186fd019bf5d7aaacd18ebbc195eef642d476c3a5fdf2ef2c66a7afb2249af68da01503025c71d795ac02cbaa98a45aa6f1a
7
- data.tar.gz: 5a90a50514f7715956e8e1e57bd0a4c8d6059341e98a9185b16d0e8af99bc756fd0bceca45035db6bd3753f30f180b890547196d19494f1ec770e422004eda95
6
+ metadata.gz: 05dfc99cebe098144c8953a8802c04a1403a3491be8460cfafd9c002f269f411011bcecd732923ef3c785cfeea5c0dcdf2e79b7156fb5959a835bd2faa396736
7
+ data.tar.gz: 7199fdb657e5e7b4df5f6dcdc6eac413a3deeb33dc8cbd99f1ab0792d870c3715154378ea23077b55b87833dacd871eb81e201d2086429d4651dbfc6bee993a5
data/ext/gmt/gmt.c CHANGED
@@ -118,7 +118,8 @@ void Init_gmt(void)
118
118
  rb_define_alloc_func(cGMT, gmt_alloc);
119
119
  rb_define_method(cGMT, "initialize", gmt_init, 0);
120
120
  rb_define_method(cGMT, "free", gmt_release, 0);
121
- rb_define_method(cGMT, "makecpt", gmt_makecpt, -1);
122
- rb_define_method(cGMT, "pstext", gmt_pstext, -1);
123
- rb_define_method(cGMT, "psxy", gmt_psxy, -1);
121
+
122
+ rb_define_private_method(cGMT, "makecpt_c", gmt_makecpt, -1);
123
+ rb_define_private_method(cGMT, "pstext_c", gmt_pstext, -1);
124
+ rb_define_private_method(cGMT, "psxy_c", gmt_psxy, -1);
124
125
  }
data/lib/gmt.rb CHANGED
@@ -1,18 +1,78 @@
1
+ # === Generic Mapping Tools (GMT) interface for Ruby
2
+ #
3
+ # Here we will have some documentation
4
+
1
5
  class GMT
2
6
 
3
- def self.psopt(file, position, options)
4
- file_options =
5
- case position
6
- when :first
7
- { :K => nil, :> => file }
8
- when :middle
9
- { :O => nil, :K => nil, :>> => file }
10
- when :last
11
- { :O => nil, :>> => file }
7
+ private
8
+
9
+ PS_METHODS = [:pstext, :psxy]
10
+ NON_PS_METHODS = [:makecpt]
11
+
12
+ def method_c(method)
13
+ [method.to_s, 'c'].join('_').to_sym
14
+ end
15
+
16
+ class << self
17
+
18
+ def opts_normalise(options)
19
+ file = options.delete(:file)
20
+ position = options.delete(:position)
21
+ if file && position then
22
+ file_options =
23
+ case position
24
+ when :first
25
+ { :K => nil, :> => file }
26
+ when :middle
27
+ { :O => nil, :K => nil, :>> => file }
28
+ when :last
29
+ { :O => nil, :>> => file }
30
+ else
31
+ raise ArguemntError, 'position should be :first, :middle or :last'
32
+ end
33
+ options.merge(file_options)
12
34
  else
13
- raise ArguemntError, 'position should be :first, :miidle or :last'
35
+ options
14
36
  end
15
- options.merge(file_options)
37
+ end
38
+
39
+ end
40
+
41
+ public
42
+
43
+ ##
44
+ # :method: pstext
45
+ # Plot text strings on maps
46
+ # :call-seq:
47
+ # pstext(*files, options)
48
+
49
+ ##
50
+ # :method: psxy
51
+ # Plot symbols, polygons, and lines on maps
52
+ # :call-seq:
53
+ # psxy(*files, options)
54
+
55
+ PS_METHODS.each do |method|
56
+
57
+ define_method(method) do |*files, options|
58
+ self.send(method_c(method),
59
+ *files, GMT.opts_normalise(options))
60
+ end
61
+
62
+ end
63
+
64
+ ##
65
+ # :method: makecpt
66
+ # Make color palette tables
67
+ # :call-seq:
68
+ # makecpt(options)
69
+
70
+ NON_PS_METHODS.each do |method|
71
+
72
+ define_method(method) do |*args|
73
+ self.send(method_c(method), *args)
74
+ end
75
+
16
76
  end
17
77
 
18
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.J. Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-30 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler