Class: Sevgi::Graphics::Element
- Inherits:
-
Object
- Object
- Sevgi::Graphics::Element
- Extended by:
- Ident
- Defined in:
- lib/sevgi/graphics/element.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Ident
Constant Summary collapse
- RootParent =
Object.new.tap { |this| def this.inspect = "RootParent" }.freeze
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(name, attributes: {}, contents: [], parent:, &block) ⇒ Element
constructor
A new instance of Element.
- #method_missing(name, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Methods included from Ident
Constructor Details
#initialize(name, attributes: {}, contents: [], parent:, &block) ⇒ Element
Returns a new instance of Element.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sevgi/graphics/element.rb', line 20 def initialize(name, attributes: {}, contents: [], parent:, &block) @name = name @attributes = Attributes.new(attributes) @contents = contents @parent = parent @children = [] parent.children << self unless self.class.root?(self) instance_exec(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
18 19 20 |
# File 'lib/sevgi/graphics/element.rb', line 18 def attributes @attributes end |
#children ⇒ Object
Returns the value of attribute children.
18 19 20 |
# File 'lib/sevgi/graphics/element.rb', line 18 def children @children end |
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
18 19 20 |
# File 'lib/sevgi/graphics/element.rb', line 18 def contents @contents end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/sevgi/graphics/element.rb', line 18 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
18 19 20 |
# File 'lib/sevgi/graphics/element.rb', line 18 def parent @parent end |