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.
38 39 40 41 42 |
# File 'lib/parser/comment.rb', line 38 def initialize(comment_text = "") @original_comment = comment_text @tokenlines, @doclines, @children = [], [], [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
36 37 38 |
# File 'lib/parser/comment.rb', line 36 def children @children end |
#doclines ⇒ Object (readonly)
Returns the value of attribute doclines.
36 37 38 |
# File 'lib/parser/comment.rb', line 36 def doclines @doclines end |
#tokenlines ⇒ Object (readonly)
Returns the value of attribute tokenlines.
36 37 38 |
# File 'lib/parser/comment.rb', line 36 def tokenlines @tokenlines end |
Instance Method Details
#add_children(comments) ⇒ Object
56 57 58 |
# File 'lib/parser/comment.rb', line 56 def add_children(comments) @children += comments end |
#add_docline(docline) ⇒ Object
51 52 53 |
# File 'lib/parser/comment.rb', line 51 def add_docline(docline) @doclines << docline end |
#add_tokenline(tokenname, content = "") ⇒ Object
46 47 48 |
# File 'lib/parser/comment.rb', line 46 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 |