123456789_123456789_123456789_123456789_123456789_

Class: RBS::AST::Comment

Relationships & Source Files
Inherits: Object
Defined in: lib/rbs/ast/comment.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(string:, location:) ⇒ Comment

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 7

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

Instance Attribute Details

#location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 5

attr_reader :location

#string (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 4

attr_reader :string

Instance Method Details

#==(other) Also known as: #eql?

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 12

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

#concat(string:, location:)

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 26

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

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

  self
end

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 16

alias eql? ==

#hash

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 18

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

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/ast/comment.rb', line 22

def to_json(state = _ = nil)
  { string: string, location: location }.to_json(state)
end