Method: Lazydoc::Comment#comment
- Defined in:
- lib/lazydoc/comment.rb
#comment(fragment_sep = " ", line_sep = "\n", strip = true) ⇒ Object
Returns content as a string where line fragments are joined by fragment_sep and lines are joined by line_sep.
292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/lazydoc/comment.rb', line 292 def comment(fragment_sep=" ", line_sep="\n", strip=true) lines = content.collect {|line| line.join(fragment_sep)} # strip leading an trailing whitespace lines if strip lines.shift while !lines.empty? && lines[0].empty? lines.pop while !lines.empty? && lines[-1].empty? end line_sep ? lines.join(line_sep) : lines end |