Class: Element
- Inherits:
-
Object
- Object
- Element
- Defined in:
- lib/rsyntaxtree/element.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#id ⇒ Object
Returns the value of attribute id.
-
#indent ⇒ Object
Returns the value of attribute indent.
-
#level ⇒ Object
Returns the value of attribute level.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#triangle ⇒ Object
Returns the value of attribute triangle.
-
#type ⇒ Object
Returns the value of attribute type.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#dump ⇒ Object
Debug helper function.
-
#initialize(id = 0, parent = 0, content = "", level = 0, type = ETYPE_LEAF) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(id = 0, parent = 0, content = "", level = 0, type = ETYPE_LEAF) ⇒ Element
Returns a new instance of Element.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rsyntaxtree/element.rb', line 37 def initialize(id = 0, parent = 0, content = "", level = 0, type = ETYPE_LEAF) @id = id # Unique element id @parent = parent # Parent element id @type = type # Element type @level = level # Element level in the tree (0=top etc...) @width = 0 # Width of the element in pixels @indent = 0 # Drawing offset # content = content.strip if /\A.+\^\z/ =~ content.strip @content = content.gsub("^"){""} # The actual element content @triangle = true # draw triangle instead of stright bar when in auto mode else @content = content.gsub("^"){""} # The actual element content @triangle = false # draw triangle instead of stright bar when in auto mode end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def content @content end |
#id ⇒ Object
Returns the value of attribute id.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def id @id end |
#indent ⇒ Object
Returns the value of attribute indent.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def indent @indent end |
#level ⇒ Object
Returns the value of attribute level.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def level @level end |
#parent ⇒ Object
Returns the value of attribute parent.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def parent @parent end |
#triangle ⇒ Object
Returns the value of attribute triangle.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def triangle @triangle end |
#type ⇒ Object
Returns the value of attribute type.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def type @type end |
#width ⇒ Object
Returns the value of attribute width.
36 37 38 |
# File 'lib/rsyntaxtree/element.rb', line 36 def width @width end |
Instance Method Details
#dump ⇒ Object
Debug helper function
55 56 57 58 59 60 61 62 63 |
# File 'lib/rsyntaxtree/element.rb', line 55 def dump printf( "ID : %d\n", @id ); printf( "Parent : %d\n", @parent ); printf( "Level : %d\n", @level ); printf( "Type : %d\n", @type ); printf( "Width : %d\n", @width ); printf( "Indent : %d\n", @indent ); printf( "Content : %s\n\n", @content ); end |