Class: Postsvg::Svg::Elements::Rect

Inherits:
Postsvg::Svg::Element show all
Defined in:
lib/postsvg/svg/elements/rect.rb

Constant Summary collapse

ELEMENT_NAME =
"rect"

Constants inherited from Postsvg::Svg::Element

Postsvg::Svg::Element::REGISTRY

Instance Attribute Summary collapse

Attributes inherited from Postsvg::Svg::Element

#attributes, #children, #clip_path_id, #transform

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Postsvg::Svg::Element

#default_fill, #element_name, register, registry

Constructor Details

#initialize(x:, y:, width:, height:, rx:, ry:, fill:, stroke_paint:, stroke:, **rest) ⇒ Rect

Returns a new instance of Rect.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/postsvg/svg/elements/rect.rb', line 13

def initialize(x:, y:, width:, height:, rx:, ry:, fill:,
               stroke_paint:, stroke:, **rest)
  super(**rest)
  @x = x
  @y = y
  @width = width
  @height = height
  @rx = rx
  @ry = ry
  @fill = fill
  @stroke_paint = stroke_paint
  @stroke = stroke
end

Instance Attribute Details

#fillObject (readonly)

Returns the value of attribute fill.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def fill
  @fill
end

#heightObject (readonly)

Returns the value of attribute height.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def height
  @height
end

#rxObject (readonly)

Returns the value of attribute rx.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def rx
  @rx
end

#ryObject (readonly)

Returns the value of attribute ry.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def ry
  @ry
end

#strokeObject (readonly)

Returns the value of attribute stroke.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def stroke
  @stroke
end

#stroke_paintObject (readonly)

Returns the value of attribute stroke_paint.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def stroke_paint
  @stroke_paint
end

#widthObject (readonly)

Returns the value of attribute width.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



10
11
12
# File 'lib/postsvg/svg/elements/rect.rb', line 10

def y
  @y
end

Class Method Details

.from_node(node) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/postsvg/svg/elements/rect.rb', line 27

def self.from_node(node)
  new(x: AttributeParser.number(node["x"], default: 0),
      y: AttributeParser.number(node["y"], default: 0),
      width: AttributeParser.number(node["width"], default: 0),
      height: AttributeParser.number(node["height"], default: 0),
      rx: AttributeParser.number(node["rx"]),
      ry: AttributeParser.number(node["ry"]),
      fill: Paint.parse(node["fill"]),
      stroke_paint: Paint.parse(node["stroke"]),
      stroke: Stroke.parse(node),
      transform: TransformList.parse(node["transform"]),
      clip_path_id: Elements.parse_clip_path_id(node["clip-path"]),
      attributes: Elements.node_attributes(node))
end