Class: RBS::AST::Annotation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string:, location:) ⇒ Annotation

Returns a new instance of Annotation.



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

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



5
6
7
# File 'lib/rbs/ast/annotation.rb', line 5

def location
  @location
end

#stringObject (readonly)

Returns the value of attribute string.



4
5
6
# File 'lib/rbs/ast/annotation.rb', line 4

def string
  @string
end

Instance Method Details

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



12
13
14
# File 'lib/rbs/ast/annotation.rb', line 12

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

#hashObject



18
19
20
# File 'lib/rbs/ast/annotation.rb', line 18

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

#to_json(*a) ⇒ Object



22
23
24
# File 'lib/rbs/ast/annotation.rb', line 22

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