Class: Postsvg::Svg::Elements::Circle

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

Constant Summary collapse

ELEMENT_NAME =
"circle"

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(cx:, cy:, r:, fill:, stroke_paint:, stroke:, **rest) ⇒ Circle

Returns a new instance of Circle.



12
13
14
15
16
17
18
19
20
# File 'lib/postsvg/svg/elements/circle.rb', line 12

def initialize(cx:, cy:, r:, fill:, stroke_paint:, stroke:, **rest)
  super(**rest)
  @cx = cx
  @cy = cy
  @r = r
  @fill = fill
  @stroke_paint = stroke_paint
  @stroke = stroke
end

Instance Attribute Details

#cxObject (readonly)

Returns the value of attribute cx.



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

def cx
  @cx
end

#cyObject (readonly)

Returns the value of attribute cy.



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

def cy
  @cy
end

#fillObject (readonly)

Returns the value of attribute fill.



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

def fill
  @fill
end

#rObject (readonly)

Returns the value of attribute r.



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

def r
  @r
end

#strokeObject (readonly)

Returns the value of attribute stroke.



10
11
12
# File 'lib/postsvg/svg/elements/circle.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/circle.rb', line 10

def stroke_paint
  @stroke_paint
end

Class Method Details

.from_node(node) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/postsvg/svg/elements/circle.rb', line 22

def self.from_node(node)
  new(cx: AttributeParser.number(node["cx"], default: 0),
      cy: AttributeParser.number(node["cy"], default: 0),
      r: AttributeParser.number(node["r"], default: 0),
      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