Class: Parser::Comment
- Inherits:
-
Object
- Object
- Parser::Comment
- Includes:
- CodeObject::Converter, MetaContainer
- Defined in:
- lib/parser/comment.rb
Overview
Comment contains all tokenlines and doclines, which are created by the parser. The tokenlines are stored as Tokenline. Because of this Comment and Tokenline act as Interface for CodeObject::Base.
The tokens will further be processed by Token::Container, which is mixed in to CodeObject::Base).
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#doclines ⇒ Object
readonly
Returns the value of attribute doclines.
-
#tokenlines ⇒ Object
readonly
Returns the value of attribute tokenlines.
Attributes included from CodeObject::Converter
Attributes included from MetaContainer
#filepath, #line_start, #source
Instance Method Summary collapse
- #add_children(comments) ⇒ Object
- #add_docline(docline) ⇒ Object
- #add_tokenline(tokenname, content = "") ⇒ Object
- #has_tokens? ⇒ Boolean
-
#initialize(comment_text = "") ⇒ Comment
constructor
A new instance of Comment.
- #to_s ⇒ Object
Methods included from CodeObject::Converter
Methods included from MetaContainer
Constructor Details
#initialize(comment_text = "") ⇒ Comment
Returns a new instance of Comment.
37 38 39 40 41 |
# File 'lib/parser/comment.rb', line 37 def initialize(comment_text = "") @original_comment = comment_text @tokenlines, @doclines, @children = [], [], [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
35 36 37 |
# File 'lib/parser/comment.rb', line 35 def children @children end |
#doclines ⇒ Object (readonly)
Returns the value of attribute doclines.
35 36 37 |
# File 'lib/parser/comment.rb', line 35 def doclines @doclines end |
#tokenlines ⇒ Object (readonly)
Returns the value of attribute tokenlines.
35 36 37 |
# File 'lib/parser/comment.rb', line 35 def tokenlines @tokenlines end |
Instance Method Details
#add_children(comments) ⇒ Object
55 56 57 |
# File 'lib/parser/comment.rb', line 55 def add_children(comments) @children += comments end |
#add_docline(docline) ⇒ Object
50 51 52 |
# File 'lib/parser/comment.rb', line 50 def add_docline(docline) @doclines << docline end |
#add_tokenline(tokenname, content = "") ⇒ Object
45 46 47 |
# File 'lib/parser/comment.rb', line 45 def add_tokenline(tokenname, content = "") @tokenlines << Tokenline.new(tokenname.to_sym, content) end |
#has_tokens? ⇒ Boolean
60 61 62 |
# File 'lib/parser/comment.rb', line 60 def has_tokens? not @tokenlines.empty? end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/parser/comment.rb', line 64 def to_s "#<Parser::Comment tokenlines=#{@tokenlines.length} doclines=#{@doclines.length}>" end |