Sha256: 4adc5065adfe68dd3906908f8c202067d023dc2e52ebc4e73215a18dfeea2113

Contents?: true

Size: 605 Bytes

Versions: 8

Compression:

Stored size: 605 Bytes

Contents

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
sdoc-1.0.0.rc2 lib/sdoc/helpers.rb
sdoc-1.0.0.rc1 lib/sdoc/helpers.rb
sdoc-1.0.0.beta2 lib/sdoc/helpers.rb
sdoc-1.0.0.beta1 lib/sdoc/helpers.rb
sdoc-0.4.2 lib/sdoc/helpers.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sdoc-0.4.1/lib/sdoc/helpers.rb
sdoc-0.4.1 lib/sdoc/helpers.rb
sdoc-0.4.0 lib/sdoc/helpers.rb