Class: Shaf::ApiDoc::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/api_doc/comment.rb

Instance Method Summary collapse

Constructor Details

#initializeComment

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

Returns:

  • (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_sObject



9
10
11
# File 'lib/shaf/api_doc/comment.rb', line 9

def to_s
  @comment
end