Class: OrgParse::Node
- Inherits:
-
Object
- Object
- OrgParse::Node
- Defined in:
- lib/org-parse/node.rb
Overview
syntax tree node
children is Node array
Node kind
- ROOT
-
RootNode
lines (StructParser)
- SECTION
-
SectionNode
- HEADLINE
-
HeadlineNode
- FN_DEFINE
-
footnote definition
- VARIABLE
-
VarNode
- WHITELINE
-
WhitelineNode
- TEXTBLOCK
-
TextlineNode’s list will become paragraph
- TEXTLINE
-
TextlineNode
- QUOTE
-
HTML quoted text
- BLOCK
-
BlockNode (verse, example, src, html, …)
- UNORDERED_LIST
-
Unorderd list <UL>
- ENUMLIST
-
Ordered list <OL>
- DESCLIST
-
Description list <DL>
- LISTITEM
-
ListitemNode
- TABLE
-
TableNode
- TABLE_SEP
-
separator between th and td
- TABLE_ROW
-
TableRowNode
inlines (InlineParser)
- BOLD
-
bold
- ITALIC
-
italic
- UNDER_LINE
-
under line
- VERBATIM
-
verbatim
- STRIKE_THROUGH
-
strike through
- CODE
-
code
- LINK
-
LinkNode 参照
- QUOTE
-
@<br/> , #+HTML … 等
Direct Known Subclasses
BlockNode, HeadlineNode, LinkNode, ListitemNode, RootNode, SectionNode, TableNode, TableRowNode, TextlineNode, VarNode, WhitelineNode
Instance Attribute Summary collapse
-
#children ⇒ Object
child nodes.
-
#kind ⇒ Object
Node type.
-
#parent ⇒ Object
Parent node.
-
#value ⇒ Object
Node value.
Instance Method Summary collapse
- #done ⇒ Object
- #done? ⇒ Boolean
- #example? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(kind = nil, children = [], value = nil) ⇒ Node
constructor
A new instance of Node.
-
#inspect ⇒ Object
def is_container? [:SECTION, :TEXTBLOCK, :LISTITEM, :UNORDERED_LIST, :ENUMLIST, :DESCLIST, :BLOCK].include? @kind end.
- #is_leaf? ⇒ Boolean
- #section_no_array ⇒ Object
- #set_example ⇒ Object
- #set_html ⇒ Object
- #set_src ⇒ Object
- #set_to_descendant(method, val = nil) ⇒ Object
- #set_verse ⇒ Object
- #src? ⇒ Boolean
- #verse? ⇒ Boolean
Constructor Details
#initialize(kind = nil, children = [], value = nil) ⇒ Node
Returns a new instance of Node.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/org-parse/node.rb', line 50 def initialize(kind = nil, children = [], value = nil) @kind = kind @children = children @value = value @done = false @parent = nil @verse = false @example = false @html = false @src = false end |
Instance Attribute Details
#children ⇒ Object
child nodes
44 45 46 |
# File 'lib/org-parse/node.rb', line 44 def children @children end |
#kind ⇒ Object
Node type
42 43 44 |
# File 'lib/org-parse/node.rb', line 42 def kind @kind end |
#parent ⇒ Object
Parent node
48 49 50 |
# File 'lib/org-parse/node.rb', line 48 def parent @parent end |
#value ⇒ Object
Node value
46 47 48 |
# File 'lib/org-parse/node.rb', line 46 def value @value end |
Instance Method Details
#done ⇒ Object
98 99 100 |
# File 'lib/org-parse/node.rb', line 98 def done @done = true end |
#done? ⇒ Boolean
94 95 96 |
# File 'lib/org-parse/node.rb', line 94 def done? @done end |
#example? ⇒ Boolean
74 75 76 |
# File 'lib/org-parse/node.rb', line 74 def example? @example end |
#html? ⇒ Boolean
90 91 92 |
# File 'lib/org-parse/node.rb', line 90 def html? @html end |
#inspect ⇒ Object
def is_container?
[:SECTION, :TEXTBLOCK, :LISTITEM, :UNORDERED_LIST, :ENUMLIST, :DESCLIST, :BLOCK].include? @kind
end
110 111 112 113 114 115 116 |
# File 'lib/org-parse/node.rb', line 110 def inspect c = '' c = @children.collect{|i| indent2(i.inspect)}.join("\n") if @children val = @value ? @value.to_s : '(nil)' val = val.is_a?( Array) ? val.join(",") : val.gsub("\n", ' ') "<#{self.class.name} #{@kind}:#{val}>" + (c.empty? ? "" : "\n") + c end |
#is_leaf? ⇒ Boolean
102 103 104 |
# File 'lib/org-parse/node.rb', line 102 def is_leaf? @children.empty? end |
#section_no_array ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/org-parse/node.rb', line 118 def section_no_array if @section_no @section_no.split('.') else nil end end |
#set_example ⇒ Object
70 71 72 |
# File 'lib/org-parse/node.rb', line 70 def set_example @example = true end |
#set_html ⇒ Object
86 87 88 |
# File 'lib/org-parse/node.rb', line 86 def set_html @html = true end |
#set_src ⇒ Object
78 79 80 |
# File 'lib/org-parse/node.rb', line 78 def set_src @src = true end |
#set_to_descendant(method, val = nil) ⇒ Object
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/org-parse/node.rb', line 126 def set_to_descendant(method, val=nil) @children.each{|node| if val node.send method, *val else node.send method end node.set_to_descendant method, val } end |
#set_verse ⇒ Object
62 63 64 |
# File 'lib/org-parse/node.rb', line 62 def set_verse @verse = true end |
#src? ⇒ Boolean
82 83 84 |
# File 'lib/org-parse/node.rb', line 82 def src? @src end |
#verse? ⇒ Boolean
66 67 68 |
# File 'lib/org-parse/node.rb', line 66 def verse? @verse end |