svgle 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f7ddc0bb3476bf997bd0e04c30b86d76738d2d6
4
- data.tar.gz: 5b31965da5698a14262fe4cbd2611530418e8d33
3
+ metadata.gz: 69eca805f2560b1d9b85b03678c7f9046a534440
4
+ data.tar.gz: a4b5d64859f9b143fe5a943cfb55da209f3942ad
5
5
  SHA512:
6
- metadata.gz: 90511e09064d67305a03023050decf6e36433bba1578a05320fdfa6d285b52c7b77c206da8bb6e3aea2d86eafcca9dbf0fb852a26f988bf98a6afbde58b4b887
7
- data.tar.gz: 3b7063f7035d1b02107f42687f9c0dd155dd4849ceb61c16b334b111d83bf6d07027368c23a57854a94ad2bce317f4d7e4b5521b2db69d1cfa210704943eb576
6
+ metadata.gz: db8d0fc540d8572e7a856cf2f0d417888dd40c24e2809c7f60573db8b5d91798ebff1cdabbdb99631530b7ee975d4fde74547627209eb388e1d6ae8b98b326ad
7
+ data.tar.gz: 7ce7fc827cd0b04045b7ef0bef3f41999155b969ab584b2a8562e8be4ef948b74a6e891182ed841eb412e9ca7e995bb15206fe19e6a6c8447a0d884fcd39d4e3
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- !B�T<�<���4ϟ�6�-��V6lI��`QtR�q�JQ�&h���VH��*]�2df\�T�D�E�q_�q=���)L�@����E<8Hds5h��l���ƒB� ��Ü��#�Jj`�(��`�P��5�h�Nļ� @#֊�~��)�N��-Z5��4s-�Wh��YyZm�
1
+ c� ��+ͬ��x���aTD��r��p��|�F9C�q��UuA���+2\���Ѓ�f�6)eC}��_���)z'�~�8T~��Xg�t����쾨�³��4
2
+ Z/_��!��Ɇ�ږ�ޱ����Nwom9�s�pRQ���}W��R
data/lib/svgle.rb CHANGED
@@ -24,13 +24,23 @@ class Style < Hash
24
24
 
25
25
  super(k,v)
26
26
  @parent[:style] = self.map{|x| x.join(':') }.join(';')
27
+ @parent.callback.refresh
27
28
 
28
29
  end
29
30
  end
30
31
 
31
32
  class Attributes
32
33
 
33
- def style
34
+ attr_reader :callback
35
+
36
+ def initialize(parent: nil)
37
+ @callback = parent
38
+ end
39
+
40
+ def style(parent=nil)
41
+
42
+ @callback ||= parent
43
+
34
44
  if @style.nil? then
35
45
 
36
46
  h = self[:style].split(';').inject({}) do |r, x|
@@ -52,6 +62,9 @@ class Svgle < Rexle
52
62
 
53
63
  class Element < Rexle::Element
54
64
 
65
+ def initialize(name=nil, value: nil, attributes: Attributes.new(parent: self), rexle: nil)
66
+ super(name, value: value, attributes: attributes, rexle: rexle)
67
+ end
55
68
 
56
69
  def self.attr2_accessor(*a)
57
70
 
@@ -67,6 +80,8 @@ class Svgle < Rexle
67
80
 
68
81
  define_method (attribute.to_s + '=').to_sym do |val|
69
82
  attributes[attribute] = val
83
+ @rexle.refresh
84
+ val
70
85
  end
71
86
 
72
87
  end
@@ -74,7 +89,7 @@ class Svgle < Rexle
74
89
  end
75
90
 
76
91
  def style()
77
- attributes.style
92
+ attributes.style(@rexle)
78
93
  end
79
94
  end
80
95
 
@@ -85,8 +100,12 @@ class Svgle < Rexle
85
100
  end
86
101
 
87
102
  class Circle < Element
88
- attr2_accessor *%i(cx cy r rx ry stroke stroke-width)
89
- end
103
+ attr2_accessor *%i(cx cy r stroke stroke-width)
104
+ end
105
+
106
+ class Ellipse < Element
107
+ attr2_accessor *%i(cx cy rx ry)
108
+ end
90
109
 
91
110
  class G < Element
92
111
  attr2_accessor *%i(fill opacity)
@@ -121,6 +140,15 @@ class Svgle < Rexle
121
140
  end
122
141
 
123
142
 
143
+ def initialize(x=nil,callback: nil)
144
+ super x
145
+ @callback = callback
146
+ end
147
+
148
+ def refresh()
149
+ @callback.refresh if @callback
150
+ end
151
+
124
152
  def scan_element(name, attributes=nil, *children)
125
153
 
126
154
  return Rexle::CData.new(children.first) if name == '!['
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file