Class: RBS::Inline::AST::Members::RBSIvar
- Defined in:
- lib/rbs/inline/ast/members.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
readonly
: Annotations::IvarType.
-
#comment ⇒ Object
readonly
: AnnotationParser::ParsingResult.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(comment, annotation) ⇒ RBSIvar
constructor
A new instance of RBSIvar.
-
#rbs ⇒ Object
: RBS::AST::Members::InstanceVariable | RBS::AST::Members::ClassInstanceVariable | nil.
Methods inherited from Base
Constructor Details
#initialize(comment, annotation) ⇒ RBSIvar
Returns a new instance of RBSIvar.
521 522 523 524 525 526 |
# File 'lib/rbs/inline/ast/members.rb', line 521 def initialize(comment, annotation) #: void @comment = comment @annotation = annotation super(comment.comments[0].location) end |
Instance Attribute Details
#annotation ⇒ Object (readonly)
: Annotations::IvarType
515 516 517 |
# File 'lib/rbs/inline/ast/members.rb', line 515 def annotation @annotation end |
#comment ⇒ Object (readonly)
: AnnotationParser::ParsingResult
517 518 519 |
# File 'lib/rbs/inline/ast/members.rb', line 517 def comment @comment end |
Instance Method Details
#rbs ⇒ Object
: RBS::AST::Members::InstanceVariable | RBS::AST::Members::ClassInstanceVariable | nil
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/rbs/inline/ast/members.rb', line 528 def rbs #: RBS::AST::Members::InstanceVariable | RBS::AST::Members::ClassInstanceVariable | nil if annotation.type if annotation.comment string = annotation.comment.delete_prefix("--").lstrip comment = RBS::AST::Comment.new(string: string, location: nil) end if annotation.class_instance RBS::AST::Members::ClassInstanceVariable.new( name: annotation.name, type: annotation.type, location: nil, comment: comment ) else RBS::AST::Members::InstanceVariable.new( name: annotation.name, type: annotation.type, location: nil, comment: comment ) end end end |