Class: Glaemscribe::API::Glaeml::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/api/glaeml.rb

Defined Under Namespace

Classes: Type

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argsObject

Returns the value of attribute args.



97
98
99
# File 'lib/api/glaeml.rb', line 97

def args
  @args
end

#childrenObject (readonly)

Returns the value of attribute children.



98
99
100
# File 'lib/api/glaeml.rb', line 98

def children
  @children
end

#lineObject

Returns the value of attribute line.



92
93
94
# File 'lib/api/glaeml.rb', line 92

def line
  @line
end

#nameObject (readonly)

Returns the value of attribute name.



95
96
97
# File 'lib/api/glaeml.rb', line 95

def name
  @name
end

#parent_nodeObject

Returns the value of attribute parent_node.



100
101
102
# File 'lib/api/glaeml.rb', line 100

def parent_node
  @parent_node
end

#typeObject (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

Returns:

  • (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

#text?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/api/glaeml.rb', line 54

def text?
  @type == Type::Text
end