Class: Jade::Frontend::CommentAttacher::CommentGroup

Inherits:
Data
  • Object
show all
Defined in:
lib/jade/frontend/comment_attacher.rb

Class Method Summary collapse

Class Method Details

.from_comments(entries) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/jade/frontend/comment_attacher.rb', line 110

def self.from_comments(entries)
  by_type = entries.group_by(&:class)
  new(
    leading:  (by_type[CommentEntry::Leading]  || []).map(&:comment),
    trailing: (by_type[CommentEntry::Trailing] || []).map(&:comment),
    dangling: (by_type[CommentEntry::Dangling] || []).map(&:comment),
  )
end