svg 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 (2) hide show
  1. data/lib/svg.rb +0 -136
  2. metadata +3 -3
data/lib/svg.rb CHANGED
@@ -1,50 +1,4 @@
1
- #require 'svg'
2
- #require 'svg/feature'
3
- #require 'svg/circle'
4
-
5
1
  module Svg
6
-
7
- class RGB
8
- def initialize(r=0, g=0, b=0)
9
- @red = r
10
- @green = g
11
- @blue = b
12
- end
13
- def red
14
- @red
15
- end
16
- def green
17
- @green
18
- end
19
- def blue
20
- @blue
21
- end
22
- def to_s
23
- return "rgb(#{@red},#{@green},#{@blue})"
24
- end
25
- end
26
-
27
- class Style < String
28
- attr_accessor :fill, :stroke, :stroke_width, :opacity, :fill_opacity, :stroke_opacity
29
- def to_s
30
- string_val = attr_to_s 'fill', fill
31
- string_val += attr_to_s 'stroke', stroke
32
- string_val += attr_to_s 'stroke-width', stroke_width
33
- string_val += attr_to_s 'opacity', opacity
34
- string_val += attr_to_s 'fill-opacity', fill_opacity
35
- string_val += attr_to_s 'stroke-opacity', stroke_opacity
36
- if not string_val.empty?
37
- string_val.strip!
38
- string_val.chop!
39
- end
40
- return string_val
41
- end
42
- def attr_to_s (attr_name, attr_val)
43
- return '' if attr_val.nil?
44
- " #{attr_name}:#{attr_val};" if not attr_val.to_s.empty?
45
- end
46
- end
47
-
48
2
  class Feature
49
3
  attr_accessor :stroke, :stroke_width, :fill, :fill_opacity, :stroke_opacity, :style
50
4
  def to_svg
@@ -61,95 +15,5 @@ module Svg
61
15
  return_val = " #{x_attr_name}=\"#{point.x}\"" if not point.x.to_s.empty?
62
16
  return_val + " #{y_attr_name}=\"#{point.y}\"" if not point.y.to_s.empty?
63
17
  end
64
- end
65
-
66
- class Circle<Feature
67
- attr_accessor :center, :radius
68
- def to_svg
69
- string_val = "<circle"
70
-
71
- string_val += point_to_s 'cx', 'cy', center
72
-
73
- string_val += attr_to_s 'r', radius
74
- string_val += attr_to_s 'stroke', stroke
75
- string_val += attr_to_s 'stroke-width', stroke_width
76
- string_val += attr_to_s 'fill', fill
77
- if not style.nil?
78
- string_val += " style=\"#{style.to_s}\""
79
- end
80
- string_val += "/>"
81
-
82
- return string_val
83
- end
84
- end
85
-
86
- class Rectangle<Feature
87
- attr_accessor :top, :radius_x, :radius_y, :width, :height
88
- def to_svg
89
- string_val = "<rect"
90
-
91
- string_val += point_to_s 'x', 'y', top
92
-
93
- string_val += attr_to_s 'rx', radius_x
94
- string_val += attr_to_s 'ry', radius_y
95
- string_val += attr_to_s 'width', width
96
- string_val += attr_to_s 'height', height
97
- if not style.nil?
98
- string_val += " style=\"#{style.to_s}\""
99
- end
100
- string_val += "/>"
101
-
102
- return string_val
103
- end
104
-
105
- end
106
-
107
- class Ellipse<Feature
108
- attr_accessor :center, :radius_x, :radius_y
109
- def to_svg
110
- string_val = "<ellipse"
111
-
112
- if not center.nil?
113
- string_val += point_to_s 'cx', 'cy', center
114
- end
115
- string_val += attr_to_s 'rx', radius_x
116
- string_val += attr_to_s 'ry', radius_y
117
-
118
- if not style.nil?
119
- string_val += " style=\"#{style.to_s}\""
120
- end
121
- string_val += "/>"
122
-
123
- return string_val
124
- end
125
- end
126
-
127
- class Line<Feature
128
- attr_accessor :from, :to
129
- def to_svg
130
- string_val = "<line"
131
- string_val += point_to_s 'x1', 'y1', from
132
- string_val += point_to_s 'x2', 'y2', to
133
-
134
- if not style.nil?
135
- string_val += " style=\"#{style.to_s}\""
136
- end
137
- string_val += "/>"
138
-
139
- return string_val
140
- end
141
- end
142
-
143
- class Point
144
- def initialize(x=0, y=0)
145
- @x = x
146
- @y = y
147
- end
148
- def x
149
- @x
150
- end
151
- def y
152
- @y
153
- end
154
18
  end
155
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -49,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
49
  version: '0'
50
50
  segments:
51
51
  - 0
52
- hash: -346562437483372879
52
+ hash: -1171331565576579121
53
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  segments:
60
60
  - 0
61
- hash: -346562437483372879
61
+ hash: -1171331565576579121
62
62
  requirements: []
63
63
  rubyforge_project:
64
64
  rubygems_version: 1.8.24