Class: Postsvg::Svg::Elements::Line

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

Constant Summary collapse

ELEMENT_NAME =
"line"

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, #fill, #transform

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Postsvg::Svg::Element

#default_fill, #element_name, register, registry

Constructor Details

#initialize(x1:, y1:, x2:, y2:, stroke_paint:, stroke:, **rest) ⇒ Line

Returns a new instance of Line.



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

def initialize(x1:, y1:, x2:, y2:, stroke_paint:, stroke:, **rest)
  super(**rest)
  @x1 = x1
  @y1 = y1
  @x2 = x2
  @y2 = y2
  @stroke_paint = stroke_paint
  @stroke = stroke
end

Instance Attribute Details

#strokeObject (readonly)

Returns the value of attribute stroke.



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

def stroke_paint
  @stroke_paint
end

#x1Object (readonly)

Returns the value of attribute x1.



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

def x1
  @x1
end

#x2Object (readonly)

Returns the value of attribute x2.



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

def x2
  @x2
end

#y1Object (readonly)

Returns the value of attribute y1.



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

def y1
  @y1
end

#y2Object (readonly)

Returns the value of attribute y2.



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

def y2
  @y2
end

Class Method Details

.from_node(node) ⇒ Object



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

def self.from_node(node)
  new(x1: AttributeParser.number(node["x1"], default: 0),
      y1: AttributeParser.number(node["y1"], default: 0),
      x2: AttributeParser.number(node["x2"], default: 0),
      y2: AttributeParser.number(node["y2"], default: 0),
      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