class DYI::Element
Abstract class that represents a element contained in the image. @abstract @since 1.0.0
Constants
- ID_REGEXP
Attributes
Returns a description of the element. @return [String] a description of the element @since 1.1.1
Returns a title of the element. @return [String] a title of the element @since 1.1.1
Public Instance Methods
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
Returns an array of child elements. @return [Array<Element>] an empty array
# File lib/dyi/element.rb, line 79 def child_elements [] end
Returns whether the element has URI reference. @return [Boolean] always false
# File lib/dyi/element.rb, line 91 def has_uri_reference? false end
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
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
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
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