Module: TreeUtils

Included in:
Kramdown::Element
Defined in:
lib/jay_flavored_markdown/markdown_converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



258
259
260
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 258

def parent
  @parent
end

Instance Method Details

#ancestor?(type) ⇒ Boolean

Returns:

  • (Boolean)


287
288
289
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 287

def ancestor?(type)
  parents.map(&:type).include?(type)
end

#find_first_ancestor(type) ⇒ Object



277
278
279
280
281
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 277

def find_first_ancestor(type)
  parents.find do |parent|
    parent.type == type
  end
end


260
261
262
263
264
265
266
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 260

def make_parent_link
  @children.each do |child|
    child.parent = self
    child.make_parent_link
  end
  return self
end

#parent?(type) ⇒ Boolean

Returns:

  • (Boolean)


283
284
285
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 283

def parent?(type)
  parent && parent.type == type
end

#parentsObject



268
269
270
271
272
273
274
275
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 268

def parents
  ps = []
  el = self
  while el = el.parent
    ps << el
  end
  return ps
end