Class: Jekyll::TreeNode

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-semtree/tree.rb

Overview

def to_s

  "<Node text: '#{@text}', ancestors: #{@ancestors}, children: #{@children}"
end

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, ancestors = [], level = -1,, line = -1,, children = [], doc = "") ⇒ TreeNode

Returns a new instance of TreeNode.



435
436
437
438
439
440
441
442
443
444
# File 'lib/jekyll-semtree/tree.rb', line 435

def initialize(text, ancestors=[], level=-1, line=-1, children=[], doc="")
  # mandatory
  @text = text
  @ancestors = ancestors
  # optional
  @children = children
  @level = level
  @line = line
  @doc = doc
end

Instance Attribute Details

#ancestorsObject

array of strings for the text of each node from root to current (leaf)



425
426
427
# File 'lib/jekyll-semtree/tree.rb', line 425

def ancestors
  @ancestors
end

#childrenObject

array of strings for the text of each child node



426
427
428
# File 'lib/jekyll-semtree/tree.rb', line 426

def children
  @children
end

#docObject

the associated jekyll document



427
428
429
# File 'lib/jekyll-semtree/tree.rb', line 427

def doc
  @doc
end

#idObject

doc properties



424
425
426
# File 'lib/jekyll-semtree/tree.rb', line 424

def id
  @id
end

#levelObject

level in the tree



428
429
430
# File 'lib/jekyll-semtree/tree.rb', line 428

def level
  @level
end

#lineObject

Returns the value of attribute line.



429
430
431
# File 'lib/jekyll-semtree/tree.rb', line 429

def line
  @line
end

#textObject

line of the index file content does not include stripped content (e.g. yaml); value for index docs is -1



432
433
434
# File 'lib/jekyll-semtree/tree.rb', line 432

def text
  @text
end

#urlObject

jekyll blog url for the given node/page



433
434
435
# File 'lib/jekyll-semtree/tree.rb', line 433

def url
  @url
end

Instance Method Details

#missingObject



446
447
448
449
# File 'lib/jekyll-semtree/tree.rb', line 446

def missing
  return @doc == ''
  # return (@doc.nil? || (@doc.class == String))
end

#namespaceObject

for legacy ‘jekyll-namespaces’ calls



474
475
476
# File 'lib/jekyll-semtree/tree.rb', line 474

def namespace
  return false
end

#titleObject



465
466
467
# File 'lib/jekyll-semtree/tree.rb', line 465

def title
  return (self.missing) ? @text : @doc.data['title']
end

#to_sObject



451
452
453
# File 'lib/jekyll-semtree/tree.rb', line 451

def to_s
  "<Node text: '#{@text}', ancestors: #{@ancestors}, children: #{@children}"
end

#typeObject



469
470
471
# File 'lib/jekyll-semtree/tree.rb', line 469

def type
  return (self.missing) ? 'zombie' : @doc.type
end