GraDA 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/grada.rb +53 -2
- metadata +2 -2
data/lib/grada.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'gnuplot'
|
2
2
|
|
3
3
|
class Grada
|
4
|
+
# Not valid the format of the object to construct the graph
|
5
|
+
#
|
4
6
|
class NotValidArrayError < RuntimeError; end
|
7
|
+
|
8
|
+
# Not valid the content of the array you're passing to build the graph
|
9
|
+
#
|
5
10
|
class NotValidDataError < RuntimeError; end
|
11
|
+
|
12
|
+
# Can't build the plot
|
13
|
+
#
|
6
14
|
class NoPlotDataError < RuntimeError; end
|
7
15
|
|
8
16
|
attr_reader :x
|
@@ -16,10 +24,25 @@ class Grada
|
|
16
24
|
with: 'lines',
|
17
25
|
graph_type: :default}
|
18
26
|
|
19
|
-
|
27
|
+
# Hello GraDA
|
28
|
+
#
|
29
|
+
|
20
30
|
def self.hi
|
21
31
|
puts "Hello GraDA"
|
22
32
|
end
|
33
|
+
|
34
|
+
# Initialize object with the data you want to plot.
|
35
|
+
# It can vary depending on the type of graph.
|
36
|
+
# The second argument is optional.
|
37
|
+
#
|
38
|
+
# Example:
|
39
|
+
# >> radiation_levels_median_per_day = [0.001,0.01,1,10,1000]
|
40
|
+
# >> radiation_days = [0,1,2,3,4]
|
41
|
+
# >> grada = Grada.new(radiation_days, radiation_levels_median_per_day)
|
42
|
+
# => #<Grada:0x007f962a8dc9b8 @x=[0, 1, 2, 3, 4], @y=[0.001, 0.01, 1, 10, 1000]>
|
43
|
+
# Arguments:
|
44
|
+
# x: (Array)
|
45
|
+
# y: (Array) *optional*
|
23
46
|
|
24
47
|
def initialize(x, y = nil)
|
25
48
|
raise NoPlotDataError if ! y.nil? && x.size != y.size
|
@@ -27,7 +50,26 @@ class Grada
|
|
27
50
|
@x = validate(x)
|
28
51
|
@y = y.nil? ? y : validate(y)
|
29
52
|
end
|
30
|
-
|
53
|
+
|
54
|
+
# Displays a graph in a window.
|
55
|
+
# You can specify all the options that you need:
|
56
|
+
# *width* (Integer)
|
57
|
+
# *height* (Integer)
|
58
|
+
# *title* (Integer)
|
59
|
+
# *x_label* (String)
|
60
|
+
# *y_label* (String)
|
61
|
+
# *graph_type* (:histogram, :heatmap) default: :default
|
62
|
+
# *with* ('points', 'linespoints') default: 'lines'
|
63
|
+
#
|
64
|
+
#
|
65
|
+
# Example:
|
66
|
+
# >> grada.display
|
67
|
+
# => ""
|
68
|
+
# >> grada.display({ title: 'Atomic Device X', x_label: 'Day', y_label: 'smSv', with: 'points' })
|
69
|
+
# => ""
|
70
|
+
# Arguments:
|
71
|
+
# opts: (Hash) *optional*
|
72
|
+
|
31
73
|
def display(opts = {})
|
32
74
|
@opts = DEFAULT_OPTIONS.merge(opts)
|
33
75
|
|
@@ -51,6 +93,15 @@ class Grada
|
|
51
93
|
end
|
52
94
|
end
|
53
95
|
|
96
|
+
# Save the graph in a png file.
|
97
|
+
# You can specify all the options that you need as _display_ but also need to specify the file
|
98
|
+
#
|
99
|
+
# Example:
|
100
|
+
# >> grada.save({ filename: 'secret/radiation_levels/ffa/zonex/devicex/radiation_level_malaga.png' ,title: 'Atomic Device X', x_label: 'Day', y_label: 'smSv', with: 'points' })
|
101
|
+
# => ""
|
102
|
+
# Arguments:
|
103
|
+
# opts: (Hash) *optional*
|
104
|
+
|
54
105
|
def save(opts = {})
|
55
106
|
@opts = DEFAULT_OPTIONS.merge(opts)
|
56
107
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: GraDA
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,7 +50,7 @@ extensions: []
|
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
52
|
- lib/grada.rb
|
53
|
-
homepage:
|
53
|
+
homepage: https://github.com/emfigo/grada
|
54
54
|
licenses: []
|
55
55
|
post_install_message:
|
56
56
|
rdoc_options: []
|