Class: RBS::AST::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/ast/comment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string:, location:) ⇒ Comment

Returns a new instance of Comment.



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

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#stringObject (readonly)

Returns the value of attribute string.



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

def string
  @string
end

Instance Method Details

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



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

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



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

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