Method: Lazydoc::Document#summarize

Defined in:
lib/lazydoc/document.rb

#summarizeObject

Summarizes constant attributes registered to self by collecting them into a nested hash of (const_name, (key, comment)) pairs. A block may be provided to collect values from the comments; each comment is yielded to the block and the return stored in it’s place.



244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/lazydoc/document.rb', line 244

def summarize
  const_hash = {}
  Document.const_attrs.each_pair do |const_name, attributes|
    next if attributes.empty?

    const_hash[const_name] = attr_hash = {}
    attributes.each_pair do |key, comment|
      next unless comment.document == self
      attr_hash[key] = (block_given? ? yield(comment) : comment)
    end
  end
  const_hash
end