svg_data_plotter_gem 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/svg_data_plotter_gem.rb +64 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d01fa50fd98a5fdf2213672031825eb72238fc00
4
- data.tar.gz: ad62d3d2141c605df402e06e6cecefaca2f616c2
3
+ metadata.gz: d7bc6f56cb55143fc9cb7be9d44c3992b95a31fe
4
+ data.tar.gz: 72fd58b0b9a9ca38fe60b1b5a5d5a5ffe503ad3c
5
5
  SHA512:
6
- metadata.gz: 934c23e9b59204ff48a45cb473199eb5011980e3e49a817ec56b2cc406c5be3c20681c22b109d811a3b0ab9072964e45804673696e01551ca398156f5be863da
7
- data.tar.gz: 851934866039c841631fd84aedb826ed4aea6a37b2045149ca963bef6cfd1472f95cb1b397180f91529eb8409f6fef7c3a0387dcd2fb6ed07a7c6f14d256e40b
6
+ metadata.gz: 28e2481b8be54e34ebacccecb3782141c43f84aac0578b53187eb018f42f1e11f750f19a0f525b6ce0c2e848ca829550a335c40fc419770d580e86a8d2f8d98d
7
+ data.tar.gz: 72b41a56e2deb403ae586f991db032d16bd56d3d517b317d8adbd4d1b7816f5687c64e69b0c0e75026d8ca36a2cb298a564cf1d738b54cb07008e3ef5323d7b5
@@ -1,7 +1,68 @@
1
1
  module SvgDataPlotterGem
2
- class Percentage
3
- def self.score
4
- puts "100%"
2
+ class Circle
3
+ def initialize(options)
4
+ validation options, [:score, :total, :size]
5
+
6
+ @score = options[:score]
7
+ @total = options[:total]
8
+ @size = options[:size]
5
9
  end
10
+
11
+ def percentage
12
+ (@score / @total.to_f) * 100
13
+ end
14
+
15
+ def center
16
+ @size / 2.0
17
+ end
18
+
19
+ def radius
20
+ center - 5.0
21
+ end
22
+
23
+ def circumference
24
+ radius * 2 * Math::PI
25
+ end
26
+
27
+ def percentage_adj
28
+ (@score / @total.to_f) * circumference
29
+ end
30
+
31
+ def radians(degrees)
32
+ degrees * Math::PI / 180
33
+ end
34
+
35
+ def x_co_ord(angle)
36
+ rad = radians(angle)
37
+ x = radius * Math.cos(rad)
38
+ center + x
39
+ end
40
+
41
+ def y_co_ord(angle)
42
+ rad = radians(angle)
43
+ y = radius * Math.sin(rad)
44
+ center - y
45
+ end
46
+
47
+ def arc_start
48
+ "#{x_co_ord(90)} #{y_co_ord(90)}"
49
+ end
50
+
51
+ def arc_end_rhs
52
+ "#{x_co_ord(270)} #{y_co_ord(270)}"
53
+ end
54
+
55
+ def arc_end_lhs
56
+ "#{x_co_ord(90)} #{y_co_ord(90)}"
57
+ end
58
+
59
+ def validation(options, params)
60
+ raise ArgumentError if options.empty?
61
+
62
+ params.each do |key|
63
+ raise ArgumentError unless options.has_key?(key)
64
+ end
65
+ end
66
+
6
67
  end
7
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg_data_plotter_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhiana Heath