Module: TreeUtils
- Included in:
- Kramdown::Element
- Defined in:
- lib/jay_flavored_markdown/markdown_converter.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #ancestor?(type) ⇒ Boolean
- #find_first_ancestor(type) ⇒ Object
- #make_parent_link ⇒ Object
- #parent?(type) ⇒ Boolean
- #parents ⇒ Object
Instance Attribute Details
#parent ⇒ Object
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
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 |
#make_parent_link ⇒ Object
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
283 284 285 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 283 def parent?(type) parent && parent.type == type end |
#parents ⇒ Object
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 |