Class: Element

Inherits:
Object
  • Object
show all
Defined in:
lib/rsyntaxtree/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = 0, parent = 0, content = NULL, level = 0, type = ETYPE_LEAF) ⇒ Element

Returns a new instance of Element.



37
38
39
40
41
42
43
44
45
# File 'lib/rsyntaxtree/element.rb', line 37

def initialize(id = 0, parent = 0, content = NULL, level = 0, type = ETYPE_LEAF)
  @id = id                 # Unique element id
  @parent = parent         # Parent element id
  @type = type             # Element type
  @content = content.strip # The actual element content
  @level = level           # Element level in the tree (0=top etc...)
  @width = 0               # Width of the element in pixels
  @indent = 0              # Drawing offset
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def content
  @content
end

#idObject

Returns the value of attribute id.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def id
  @id
end

#indentObject

Returns the value of attribute indent.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def indent
  @indent
end

#levelObject

Returns the value of attribute level.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def level
  @level
end

#parentObject

Returns the value of attribute parent.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def parent
  @parent
end

#typeObject

Returns the value of attribute type.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def type
  @type
end

#widthObject

Returns the value of attribute width.



36
37
38
# File 'lib/rsyntaxtree/element.rb', line 36

def width
  @width
end

Instance Method Details

#dumpObject

Debug helper function



48
49
50
51
52
53
54
55
56
# File 'lib/rsyntaxtree/element.rb', line 48

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