class CodeWeb::MethodList

Attributes

collection[RW]

the collection (actually [[k,],[k2,]])

name[RW]

what was used in the group by

Public Class Methods

group_by(collection, name) click to toggle source
# File lib/code_web/method_list.rb, line 56
def self.group_by(collection, name)
  MethodList.new(nil, collection).group_by(name)
end
new(name, collection) click to toggle source
# File lib/code_web/method_list.rb, line 13
def initialize(name, collection)
  @name = name
  @collection = collection
end

Public Instance Methods

arg_keys() click to toggle source
# File lib/code_web/method_list.rb, line 52
def arg_keys
  @arg_keys ||= collection.inject(Set.new) {|acc, m| m.arg_keys.each {|k| acc << k} ; acc}.sort_by {|n| n}
end
detect(&block) click to toggle source
# File lib/code_web/method_list.rb, line 42
def detect(&block)
  collection.detect(&block)
end
each() { |method_list| ... } click to toggle source
# File lib/code_web/method_list.rb, line 46
def each(&block)
  collection.each do |n, c|
    yield MethodList.new(n,c)
  end
end
f() click to toggle source
# File lib/code_web/method_list.rb, line 35
def f
  collection.first
end
group_by(name, arg_regex=nil, sort_by = nil, &block) click to toggle source
# File lib/code_web/method_list.rb, line 18
def group_by(name, arg_regex=nil, sort_by = nil, &block)
  if block.nil?
    if arg_regex.nil?
      block = Proc.new { |m| m.send(name).to_s }
    else
      block = Proc.new {|m|
        if m.hash_args?
          m.hash_arg.collect {|n,v| v if n =~ arg_regex}.compact.join(" ")
        else
          m.signature
        end
      }
    end
  end
  MethodList.new(name, collection.group_by(&block).sort_by {|n, ms| sort_by ? ms.first.send(sort_by) : n })
end