Class: GemfileSorter::CommentGroup
- Inherits:
-
Object
- Object
- GemfileSorter::CommentGroup
- Includes:
- Enumerable
- Defined in:
- lib/gemfile_sorter/comment_group.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
Instance Method Summary collapse
- #<<(comment) ⇒ Object
- #add(comment) ⇒ Object
- #contents ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #extra_line_unless_empty ⇒ Object
-
#initialize(*comments) ⇒ CommentGroup
constructor
A new instance of CommentGroup.
- #to_s ⇒ Object
Constructor Details
#initialize(*comments) ⇒ CommentGroup
Returns a new instance of CommentGroup.
7 8 9 |
# File 'lib/gemfile_sorter/comment_group.rb', line 7 def initialize(*comments) @comments = comments.flatten end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
5 6 7 |
# File 'lib/gemfile_sorter/comment_group.rb', line 5 def comments @comments end |
Instance Method Details
#<<(comment) ⇒ Object
21 |
# File 'lib/gemfile_sorter/comment_group.rb', line 21 def <<(comment) = add(comment) |
#add(comment) ⇒ Object
17 18 19 |
# File 'lib/gemfile_sorter/comment_group.rb', line 17 def add(comment) self.comments += comment.comments end |
#contents ⇒ Object
15 |
# File 'lib/gemfile_sorter/comment_group.rb', line 15 def contents = comments |
#each ⇒ Object
25 |
# File 'lib/gemfile_sorter/comment_group.rb', line 25 def each = comments.each |
#empty? ⇒ Boolean
23 |
# File 'lib/gemfile_sorter/comment_group.rb', line 23 def empty? = comments.empty? |
#extra_line_unless_empty ⇒ Object
27 28 29 |
# File 'lib/gemfile_sorter/comment_group.rb', line 27 def extra_line_unless_empty empty? ? "" : "\n" end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/gemfile_sorter/comment_group.rb', line 11 def to_s comments.map { _1.to_s }.join end |