Class: Shaf::ApiDoc::Comment
- Inherits:
-
Object
- Object
- Shaf::ApiDoc::Comment
- Defined in:
- lib/shaf/api_doc/comment.rb
Instance Method Summary collapse
- #<<(line) ⇒ Object
- #empty? ⇒ Boolean
- #extract(line) ⇒ Object
-
#initialize ⇒ Comment
constructor
A new instance of Comment.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Comment
Returns a new instance of Comment.
4 5 6 7 |
# File 'lib/shaf/api_doc/comment.rb', line 4 def initialize @indent = 0 @comment = "" end |
Instance Method Details
#<<(line) ⇒ Object
17 18 19 20 |
# File 'lib/shaf/api_doc/comment.rb', line 17 def <<(line) @indent = line[/\A\s*/].size if empty? @comment << "\n#{extract(line)}" end |
#empty? ⇒ Boolean
13 14 15 |
# File 'lib/shaf/api_doc/comment.rb', line 13 def empty? @comment.empty? end |
#extract(line) ⇒ Object
22 23 24 |
# File 'lib/shaf/api_doc/comment.rb', line 22 def extract(line) line.sub(%r(\A\s{#{@indent}}), "") end |
#to_s ⇒ Object
9 10 11 |
# File 'lib/shaf/api_doc/comment.rb', line 9 def to_s @comment end |