Sha256: 904359bcf1aa7e0ffa4a3babfab0a364b9ca98c0222d891d2302b2330d90d287

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require_relative "symbol_container.rb"

module Docks
  module Containers
    # Public: a container for Function symbols.

    class Function < Symbol
      def self.type; Docks::Types::Symbol::FUNCTION end

      def static?; fetch(:static, false) end
      def instance?; !static? end
      def method?; fetch(:method, false) end

      def symbol_id
        return super unless method?
        "method-#{"static-" if static?}#{self[:for]}-#{self[:name]}"
      end

      def to_descriptor
        return super unless method?
        "#{belongs_to.to_descriptor}#{static? ? "." : "#"}#{fetch(:name)}"
      end

      def summary
        summary = super
        summary.static = static?
        summary.method = method?
        summary.for = fetch(:for, nil)
        summary
      end

      protected

      def matches_exactly?(descriptor)
        name = fetch(:name, nil)
        is_method = method?

        matches = (!is_method && super) ||
          (is_method && instance? && descriptor.instance_member == name) ||
          (is_method && static? && descriptor.static_member == name)

        matches && self
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 lib/docks/containers/function_container.rb
docks_app-0.0.2 lib/docks/containers/function_container.rb
docks_app-0.0.1 lib/docks/containers/function_container.rb