Sha256: c5e61b4f2c93937559c24f4ed3f9fb33f7d8c24992ef4bbf2777e89157989e7b

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

module Analyst

  module Entities

    class Root < Entity

      handles_node :analyst_root

      def initialize(ast, source_data)
        @source_data = source_data
        super(ast, nil)
      end

      def full_name
        ""
      end

      def source_data_for(entity)
        source_data[actual_contents.index(entity)]
      end

      def file_path
        throw "Entity tree malformed - Source or File should have caught this call"
      end

      def origin_source
        throw "Entity tree malformed - Source or File hsould have caught this call"
      end

      def inspect
        "\#<#{self.class}>"
      end

      def contents
        # skip all top-level entities, cuz they're all Files and Sources
        @contents ||= actual_contents.map(&:contents).flatten
      end

      private

      attr_reader :source_data

      def actual_contents
        @actual_contents ||= ast.children.map { |child| process_node(child) }
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
analyst-1.0.1 lib/analyst/entities/root.rb
analyst-1.0.0 lib/analyst/entities/root.rb
analyst-0.16.1 lib/analyst/entities/root.rb