File: helpers.rb

package info (click to toggle)
ruby-sdoc 0.4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 896 kB
  • ctags: 523
  • sloc: ruby: 746; makefile: 3
file content (26 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module SDoc::Helpers
  def each_letter_group(methods, &block)
    group = {:name => '', :methods => []}
    methods.sort{ |a, b| a.name <=> b.name }.each do |method|
      gname = group_name method.name
      if gname != group[:name]
        yield group unless group[:methods].size == 0
        group = {
          :name => gname,
          :methods => []
        }
      end
      group[:methods].push(method)
    end
    yield group unless group[:methods].size == 0
  end

protected
  def group_name name
    if match = name.match(/^([a-z])/i)
      match[1].upcase
    else
      '#'
    end
  end
end