@@ -7,39 +7,39 @@ module Plottable
7
7
include OptionHandling
8
8
9
9
##
10
+ # @private
10
11
# You should implement #plot in classes that are Plottable
11
12
def plot ( *_ )
12
13
fail NotImplementedError , 'You should implement #plot in classes that are Plottable!'
13
14
end
14
15
15
16
##
16
- # ====== Overview
17
17
# In this gem #method_missing is used both to handle
18
18
# options and to handle plotting to specific terminal.
19
19
#
20
- # ====== Options handling
21
- # ======= Overview
20
+ # == Options handling
21
+ # === Overview
22
22
# You may set options using #option_name(option_value) method.
23
23
# A new object will be constructed with selected option set.
24
24
# And finally you can get current value of any option using
25
25
# #options_name without arguments.
26
- # ======= Arguments
26
+ # === Arguments
27
27
# * *option_value* - value to set an option. If none given
28
28
# method will just return current option's value
29
- # ======= Examples
29
+ # === Examples
30
30
# plot = Splot.new
31
31
# new_plot = plot.title('Awesome plot')
32
32
# plot.title #=> nil
33
33
# new_plot.title #=> 'Awesome plot'
34
34
#
35
- # ====== Plotting to specific term
36
- # ======= Overview
35
+ # == Plotting to specific term
36
+ # === Overview
37
37
# Gnuplot offers possibility to output graphics to many image formats.
38
38
# The easiest way to to so is to use #to_<plot_name> methods.
39
- # ======= Arguments
39
+ # === Arguments
40
40
# * *options* - set of options related to terminal (size, font etc).
41
41
# Be careful, some terminals have their own specific options.
42
- # ======= Examples
42
+ # === Examples
43
43
# # font options specific for png term
44
44
# multiplot.to_png('./result.png', size: [300, 500], font: ['arial', 12])
45
45
# # font options specific for svg term
@@ -62,8 +62,9 @@ def method_missing(meth_id, *args)
62
62
end
63
63
64
64
##
65
- # Returns true foe existing methods and
66
- # #to_<term_name> when name is a valid terminal type.
65
+ # @return [true] for existing methods and
66
+ # #to_|term_name| when name is a valid terminal type.
67
+ # @return [false] otherwise
67
68
def respond_to? ( meth_id )
68
69
# Next line is here to force iRuby use #to_iruby
69
70
# instead of #to_svg.
@@ -74,8 +75,7 @@ def respond_to?(meth_id)
74
75
end
75
76
76
77
##
77
- # This method is used to embed plottable objects
78
- # into iRuby notebooks. There is
78
+ # This method is used to embed plottable objects into iRuby notebooks. There is
79
79
# {a notebook}[http://nbviewer.ipython.org/github/dilcom/gnuplotrb/blob/master/notebooks/basic_usage.ipynb]
80
80
# with examples of its usage.
81
81
def to_iruby
@@ -92,20 +92,16 @@ def to_iruby
92
92
end
93
93
94
94
##
95
- # :call-seq:
96
- # to_png('file.png') -> creates file with plot
97
- # to_svg -> svg file contents
98
- # to_canvas('plot.html', size: [300,300]) -> creates file with plot
99
- #
100
- # ====== Overview
101
- # Method which outputs plot to specific terminal (possibly some file).
95
+ # @private
96
+ # Output plot to specific terminal (possibly some file).
102
97
# Explicit use should be avoided. This method is called from #method_missing
103
98
# when it handles method names like #to_png(options).
104
- # ====== Arguments
105
- # * *path* - path to output file, if none given it will output to temp file
99
+ #
100
+ # @param trminal [String] terminal name ('png', 'svg' etc)
101
+ # @param path [String] path to output file, if none given it will output to temp file
106
102
# and then read it and return binary contents of file
107
- # * * options* - used in #plot
108
- # ====== Examples
103
+ # @param options [Hash] used in #plot
104
+ # @example
109
105
# ## plot here may be Plot, Splot, Multiplot or any other plottable class
110
106
# plot.to_png('./result.png', size: [300, 500])
111
107
# contents = plot.to_svg(size: [100, 100])
@@ -123,9 +119,90 @@ def to_specific_term(terminal, path = nil, **options)
123
119
end
124
120
125
121
##
126
- # Returns terminal object linked with this Plottable object.
122
+ # @return [Terminal] terminal object linked with this Plottable object
127
123
def own_terminal
128
124
@terminal ||= Terminal . new
129
125
end
126
+
127
+ ##
128
+ # @!method xrange(value = nil)
129
+ # @!method yrange(value = nil)
130
+ # @!method title(value = nil)
131
+ # @!method option_name(value = nil)
132
+ # Clone existing object and set new options value in created one or just return
133
+ # existing value if nil given.
134
+ #
135
+ # Method is handled by #method_missing.
136
+ #
137
+ # You may set options using #option_name(option_value) method.
138
+ # A new object will be constructed with selected option set.
139
+ # And finally you can get current value of any option using
140
+ # #options_name without arguments.
141
+ #
142
+ # Available options are listed in Plot, Splot, Multiplot etc class top level doc.
143
+ #
144
+ # @param value new value for option
145
+ # @return new object with option_name set to *value* if value given
146
+ # @return old option value if no value given
147
+ #
148
+ # @example
149
+ # plot = Splot.new
150
+ # new_plot = plot.title('Awesome plot')
151
+ # plot.title #=> nil
152
+ # new_plot.title #=> 'Awesome plot'
153
+
154
+ ##
155
+ # @!method xrange!(value)
156
+ # @!method yrange!(value)
157
+ # @!method title!(value)
158
+ # @!method option_name!(value)
159
+ # Set value for an option.
160
+ #
161
+ # Method is handled by #method_missing.
162
+ #
163
+ # You may set options using obj.option_name!(option_value) or
164
+ # obj.option_name = option_value methods.
165
+ #
166
+ # Available options are listed in Plot, Splot, Multiplot etc class top level doc.
167
+ #
168
+ # @param value new value for option
169
+ # @return self
170
+ #
171
+ # @example
172
+ # plot = Splot.new
173
+ # plot.title #=> nil
174
+ # plot.title!('Awesome plot')
175
+ # plot.title #=> 'Awesome plot'
176
+ #
177
+ # @example
178
+ # plot = Splot.new
179
+ # plot.title #=> nil
180
+ # plot.title = 'Awesome plot'
181
+ # plot.title #=> 'Awesome plot'
182
+
183
+ ##
184
+ # @!method to_png(path = nil, **options)
185
+ # @!method to_svg(path = nil, **options)
186
+ # @!method to_gif(path = nil, **options)
187
+ # @!method to_canvas(path = nil, **options)
188
+ # Output to plot to according image format.
189
+ #
190
+ # All of #to_|terminal_name| methods are handled with #method_missing.
191
+ #
192
+ # Gnuplot offers possibility to output graphics to many image formats.
193
+ # The easiest way to to so is to use #to_<plot_name> methods.
194
+ #
195
+ # @param path [String] path to save plot file to.
196
+ # @param options [Hash] specific terminal options like 'size',
197
+ # 'font' etc
198
+ #
199
+ # @return [String] contents of plotted file unless path given
200
+ # @return self if path given
201
+ #
202
+ # @example
203
+ # # font options specific for png term
204
+ # multiplot.to_png('./result.png', size: [300, 500], font: ['arial', 12])
205
+ # # font options specific for svg term
206
+ # content = multiplot.to_svg(size: [100, 100], fname: 'Arial', fsize: 12)
130
207
end
131
208
end
0 commit comments