Class: Emfsvg::Svg::Elements::Line

Inherits:
Emfsvg::Svg::Element show all
Defined in:
lib/emfsvg/svg/elements/line.rb

Overview

Constant Summary collapse

ELEMENT_NAME =
"line"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Emfsvg::Svg::Element

#children, #element_name, register

Constructor Details

#initialize(x1:, y1:, x2:, y2:, fill:, stroke:, clip_path: nil) ⇒ Line

Returns a new instance of Line.



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

def initialize(x1:, y1:, x2:, y2:, fill:, stroke:, clip_path: nil)
  @x1 = x1
  @y1 = y1
  @x2 = x2
  @y2 = y2
  @fill = fill
  @stroke = stroke
  @clip_path = clip_path
end

Instance Attribute Details

#clip_pathObject (readonly)

Returns the value of attribute clip_path.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def clip_path
  @clip_path
end

#fillObject (readonly)

Returns the value of attribute fill.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def fill
  @fill
end

#strokeObject (readonly)

Returns the value of attribute stroke.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def stroke
  @stroke
end

#x1Object (readonly)

Returns the value of attribute x1.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def x1
  @x1
end

#x2Object (readonly)

Returns the value of attribute x2.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def x2
  @x2
end

#y1Object (readonly)

Returns the value of attribute y1.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def y1
  @y1
end

#y2Object (readonly)

Returns the value of attribute y2.



11
12
13
# File 'lib/emfsvg/svg/elements/line.rb', line 11

def y2
  @y2
end

Class Method Details

.from_node(node) ⇒ Object



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

def self.from_node(node)
  new(
    x1: AttributeParser.float(node["x1"]),
    y1: AttributeParser.float(node["y1"]),
    x2: AttributeParser.float(node["x2"]),
    y2: AttributeParser.float(node["y2"]),
    **Stylable.parse_style(node)
  )
end