Class: RoundRect
Instance Method Summary
collapse
Methods inherited from Element
#initialize
Constructor Details
This class inherits a constructor from Element
Instance Method Details
#<<(token) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/parsers/round_rect.rb', line 4
def <<(token)
if @tokens.empty?
raise "Invalid starting token: #{token}" unless token.first == :ROUND_RECT
w, h, rx, ry = token.last
@attributes['width'] = w
@attributes['height'] = h
@attributes['rx'] = rx
@attributes['ry'] = ry
end
if token.first == :LOCATION
x, y = token.last
@attributes['x'] = x
@attributes['y'] = y
elsif token.first == :ATTRIBUTE
k, v = token.last
@attributes[k] = v
end
super(token)
end
|
#translate ⇒ Object
26
27
28
29
|
# File 'lib/parsers/round_rect.rb', line 26
def translate
attrs = @attributes.map { |k,v| "#{k}='#{v}'" }.join(' ')
"<rect #{attrs} />"
end
|