Class: Postsvg::Svg::Elements::Image

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

Constant Summary collapse

ELEMENT_NAME =
"image"

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, #stroke, #stroke_paint, #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:, href:, **rest) ⇒ Image

Returns a new instance of Image.



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

def initialize(x:, y:, width:, height:, href:, **rest)
  super(**rest)
  @x = x
  @y = y
  @width = width
  @height = height
  @href = href
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



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

def height
  @height
end

#hrefObject (readonly)

Returns the value of attribute href.



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

def href
  @href
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



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

def y
  @y
end

Class Method Details

.from_node(node) ⇒ Object



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

def self.from_node(node)
  href = node["href"] || node["xlink:href"]
  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),
      href: href,
      transform: TransformList.parse(node["transform"]),
      clip_path_id: Elements.parse_clip_path_id(node["clip-path"]),
      attributes: Elements.node_attributes(node))
end