Sha256: f29a20ee57b466a128093da5129afeb08d7abb9e9080163d21374a35cdff575f

Contents?: true

Size: 691 Bytes

Versions: 5

Compression:

Stored size: 691 Bytes

Contents

module RBS
  module AST
    class Comment
      attr_reader :string
      attr_reader :location

      def initialize(string:, location:)
        @string = string
        @location = location
      end

      def ==(other)
        other.is_a?(Comment) && other.string == string
      end

      alias eql? ==

      def hash
        self.class.hash ^ string.hash
      end

      def to_json(*a)
        { string: string, location: location }.to_json(*a)
      end

      def concat(string:, location:)  
        @string.concat string

        if loc = @location
          loc.concat location
        else
          @location = location
        end

        self
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbs-0.13.1 lib/rbs/ast/comment.rb
rbs-0.13.0 lib/rbs/ast/comment.rb
rbs-0.12.2 lib/rbs/ast/comment.rb
rbs-0.12.1 lib/rbs/ast/comment.rb
rbs-0.12.0 lib/rbs/ast/comment.rb