Sha256: a5c2a0b1f054e7097a800779525849ba7f56b32b2b6bcd838dc55b434f44a060

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

module SFRP
  module Raw
    class Ref < Struct.new(:relative_name, :qualifier_name, :sp)
      def to_s
        return relative_name if qualifier_name.nil?
        qualifier_name + '.' + relative_name
      end
    end

    class Import < Struct.new(:absolute_namespace_name, :qualifier_name)

    end

    class Namespace
      def initialize(absolute_namespace_name, imports)
        @absolute_namespace_name = absolute_namespace_name
        @imports = [Import.new(absolute_namespace_name, nil), *imports]
      end

      def absolute_name(relative_name)
        @absolute_namespace_name + '.' + relative_name
      end

      def search_for_absolute_names(ref)
        @imports.select { |i| i.qualifier_name == ref.qualifier_name }
          .map { |i| i.absolute_namespace_name + '.' + ref.relative_name }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sfrp-1.2.1 lib/sfrp/raw/namespace.rb
sfrp-1.2.0 lib/sfrp/raw/namespace.rb
sfrp-1.1.0 lib/sfrp/raw/namespace.rb