class DYI::Element

Abstract class that represents a element contained in the image. @abstract @since 1.0.0

Constants

ID_REGEXP

Attributes

description[RW]

Returns a description of the element. @return [String] a description of the element @since 1.1.1

title[RW]

Returns a title of the element. @return [String] a title of the element @since 1.1.1

Public Instance Methods

canvas() click to toggle source

Returns the canvas where the shape is drawn. @return [Canvas] the canvas where the shape is drawn

# File lib/dyi/element.rb, line 69
def canvas
  current_node = self
  loop do
    return current_node if current_node.nil? || current_node.root_element?
    current_node = current_node.parent
  end
end
child_elements() click to toggle source

Returns an array of child elements. @return [Array<Element>] an empty array

# File lib/dyi/element.rb, line 79
def child_elements
  []
end
has_uri_reference?() click to toggle source

Returns whether the element has URI reference. @return [Boolean] always false

# File lib/dyi/element.rb, line 91
def has_uri_reference?
  false
end
id() click to toggle source

Returns id for the element. If the element has no id yet, makes id and returns it. @return [String] id for the element

# File lib/dyi/element.rb, line 44
def id
  @id ||= canvas && canvas.publish_shape_id
end
Also aliased as: publish_id
id=(value) click to toggle source

Sets id for the element. @param [String] value id for the element @return [String] id that is given @raise [ArgumentError] value is empty or illegal format

# File lib/dyi/element.rb, line 60
def id=(value)
  # TODO: veryfy that the id is unique.
  raise ArgumentError, "`#{value}' is empty" if value.to_s.size == 0
  raise ArgumentError, "`#{value}' is a illegal id" if value.to_s !~ ID_REGEXP
  @id = value.to_s
end
include_external_file?() click to toggle source

Returns whether the element has reference of external file. @return [Boolean] always false

# File lib/dyi/element.rb, line 85
def include_external_file?
  false
end
inner_id() click to toggle source

Returns id of the element. If the element has no id yet, returns nil. @return [String] id for the element if it has id, nil if not

# File lib/dyi/element.rb, line 52
def inner_id
  @id
end
publish_id()
Alias for: id