Sha256: 12c35edc4737a1567c0e212658c942331c4adb28bc6938ab046974e3d0982ece

Contents?: true

Size: 773 Bytes

Versions: 12

Compression:

Stored size: 773 Bytes

Contents

module Parser
  module Source

    class Comment
      attr_reader  :text

      attr_reader  :location
      alias_method :loc, :location

      def self.associate(ast, comments)
        associator = Associator.new(comments, ast)
        associator.associate
      end

      def initialize(location)
        @location = location
        @text     = location.source.freeze

        freeze
      end

      def type
        case text
        when /^#/
          :inline
        when /^=begin/
          :document
        end
      end

      def inline?
        type == :inline
      end

      def document?
        type == :document
      end

      def ==(other)
        other.is_a?(Source::Comment) &&
          @location == other.location
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
parser-2.0.0.pre2 lib/parser/source/comment.rb
parser-2.0.0.pre1 lib/parser/source/comment.rb
parser-2.0.0.beta10 lib/parser/source/comment.rb
parser-2.0.0.beta9 lib/parser/source/comment.rb
parser-2.0.0.beta8 lib/parser/source/comment.rb
parser-2.0.0.beta7 lib/parser/source/comment.rb
parser-2.0.0.beta6 lib/parser/source/comment.rb
parser-2.0.0.beta5 lib/parser/source/comment.rb
parser-2.0.0.beta4 lib/parser/source/comment.rb
parser-2.0.0.beta3 lib/parser/source/comment.rb
parser-2.0.0.beta2 lib/parser/source/comment.rb
parser-2.0.0.beta1 lib/parser/source/comment.rb