Class: RBS::AST::Comment

Inherits:
Object
  • Object
show all
Includes:
_ToJson
Defined in:
sig/comment.rbs,
lib/rbs/ast/comment.rb

Overview

RBS allows writing documentation of declarations and members.

# This is a doc for class.
class Hello
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string:, location:) ⇒ Comment

Returns a new instance of Comment.

Parameters:

  • string: (String)
  • location: (Location[bot, bot], nil)


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

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

Instance Attribute Details

#locationLocation[bot, bot]? (readonly)

Returns the value of attribute location.

Returns:



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

def location
  @location
end

#stringString (readonly)

Returns the value of attribute string.

Returns:

  • (String)


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

def string
  @string
end

Instance Method Details

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

Parameters:

  • other (Object)

Returns:

  • (Boolean)


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

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

#hashInteger

Returns:

  • (Integer)


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