Class: Glaemscribe::API::Glaeml::Node
- Inherits:
-
Object
- Object
- Glaemscribe::API::Glaeml::Node
- Defined in:
- lib/api/glaeml.rb
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.
- #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.
97 98 99 |
# File 'lib/api/glaeml.rb', line 97 def args @args end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
98 99 100 |
# File 'lib/api/glaeml.rb', line 98 def children @children end |
#line ⇒ Object
Returns the value of attribute line.
92 93 94 |
# File 'lib/api/glaeml.rb', line 92 def line @line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
95 96 97 |
# File 'lib/api/glaeml.rb', line 95 def name @name end |
#parent_node ⇒ Object
Returns the value of attribute parent_node.
100 101 102 |
# File 'lib/api/glaeml.rb', line 100 def parent_node @parent_node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
94 95 96 |
# File 'lib/api/glaeml.rb', line 94 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
85 86 87 88 89 90 |
# File 'lib/api/glaeml.rb', line 85 def gpath(path) apath = path.split(".") found = [] pathfind_crawl(apath, found) found end |
#pathfind_crawl(apath, found) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/api/glaeml.rb', line 70 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 |