Sha256: fd091ebf4bf161a91efa5ce5f6b4b73214add1b7fe5d8535757a56876eb276cf

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

module Dub
  class FunctionGroup < Array
    def initialize(parent, gen = nil)
      @parent, @gen = parent, gen
    end

    def bind(generator)
      self.gen = generator.function_generator
    end

    def generator
      @gen || (@parent && @parent.function_generator)
    end

    def gen=(generator)
      @gen = generator
      @gen_members = nil
    end

    alias gen generator

    def members
      if self.generator
        if @parent.generator
          @gen_members ||= @parent.generator.members_list(self)
        else
          @gen_members ||= generator.namespace_generator.members_list(self)
        end
      else
        self
      end
    end

    def to_s
      generator.group(self)
    end

    def name
      first.name
    end

    def method_name(overloaded_index = nil)
      first.method_name(overloaded_index)
    end

    def map(&block)
      list = self.class.new(@parent, @gen)
      super(&block).each do |e|
        list << e
      end
      list
    end

    def compact
      list = self.class.new(@parent, @gen)
      super.each do |e|
        list << e
      end
      list
    end

    def overloaded_index
      nil
    end

    def prefix
      first.prefix
    end

    def <=>(other)
      name <=> other.name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dub-0.5.1 lib/dub/function_group.rb
dub-0.5.0 lib/dub/function_group.rb