Class: Glaemscribe::API::Glaeml::Node
Defined Under Namespace
Classes: Type
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#line ⇒ Object
Returns the value of attribute line.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent_node ⇒ Object
Returns the value of attribute parent_node.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #element? ⇒ Boolean
- #gpath(path) ⇒ Object
-
#initialize(line, type, name) ⇒ Node
constructor
A new instance of Node.
-
#initialize_copy(other) ⇒ Object
Make our object clonable.
- #pathfind_crawl(apath, found) ⇒ Object
- #text? ⇒ Boolean
Constructor Details
#initialize(line, type, name) ⇒ Node
Returns a new instance of Node.
62 63 64 65 66 67 68 |
# File 'lib/api/glaeml.rb', line 62 def initialize(line, type, name) @line = line @type = type @name = name @args = [] @children = [] end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
104 105 106 |
# File 'lib/api/glaeml.rb', line 104 def args @args end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
105 106 107 |
# File 'lib/api/glaeml.rb', line 105 def children @children end |
#line ⇒ Object
Returns the value of attribute line.
99 100 101 |
# File 'lib/api/glaeml.rb', line 99 def line @line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
102 103 104 |
# File 'lib/api/glaeml.rb', line 102 def name @name end |
#parent_node ⇒ Object
Returns the value of attribute parent_node.
107 108 109 |
# File 'lib/api/glaeml.rb', line 107 def parent_node @parent_node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
101 102 103 |
# File 'lib/api/glaeml.rb', line 101 def type @type end |
Instance Method Details
#element? ⇒ Boolean
58 59 60 |
# File 'lib/api/glaeml.rb', line 58 def element? @type == Type::ElementInline || @type == Type::ElementBlock end |
#gpath(path) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/api/glaeml.rb', line 92 def gpath(path) apath = path.split(".") found = [] pathfind_crawl(apath, found) found end |
#initialize_copy(other) ⇒ Object
Make our object clonable
71 72 73 74 75 |
# File 'lib/api/glaeml.rb', line 71 def initialize_copy(other) super @args = other.args.clone @children = other.children.map{|c| c.clone} end |
#pathfind_crawl(apath, found) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/api/glaeml.rb', line 77 def pathfind_crawl(apath, found) children.each{ |c| if(c.name == apath[0]) if apath.count == 1 found << c else bpath = apath.dup bpath.shift c.pathfind_crawl(bpath, found) end end } end |