Class: RBS::Source::RBS
- Inherits:
-
Object
- Object
- RBS::Source::RBS
- Defined in:
- lib/rbs/source.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#declarations ⇒ Object
readonly
Returns the value of attribute declarations.
-
#directives ⇒ Object
readonly
Returns the value of attribute directives.
Instance Method Summary collapse
- #each_declaration_type_name(names, decl, &block) ⇒ Object
- #each_type_name(&block) ⇒ Object
-
#initialize(buffer, directives, decls) ⇒ RBS
constructor
A new instance of RBS.
Constructor Details
#initialize(buffer, directives, decls) ⇒ RBS
Returns a new instance of RBS.
8 9 10 11 12 |
# File 'lib/rbs/source.rb', line 8 def initialize(buffer, directives, decls) @buffer = buffer @directives = directives @declarations = decls end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
6 7 8 |
# File 'lib/rbs/source.rb', line 6 def buffer @buffer end |
#declarations ⇒ Object (readonly)
Returns the value of attribute declarations.
6 7 8 |
# File 'lib/rbs/source.rb', line 6 def declarations @declarations end |
#directives ⇒ Object (readonly)
Returns the value of attribute directives.
6 7 8 |
# File 'lib/rbs/source.rb', line 6 def directives @directives end |
Instance Method Details
#each_declaration_type_name(names, decl, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rbs/source.rb', line 25 def each_declaration_type_name(names, decl, &block) case decl when AST::Declarations::Class decl.each_decl { each_declaration_type_name(names, _1, &block) } type_name = decl.name when AST::Declarations::Module decl.each_decl { each_declaration_type_name(names, _1, &block) } type_name = decl.name when AST::Declarations::Interface type_name = decl.name when AST::Declarations::TypeAlias type_name = decl.name when AST::Declarations::ModuleAlias type_name = decl.new_name when AST::Declarations::ClassAlias type_name = decl.new_name end if type_name unless names.include?(type_name) yield type_name names << type_name end end end |
#each_type_name(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rbs/source.rb', line 14 def each_type_name(&block) if block set = Set[] #: Set[TypeName] declarations.each do |decl| each_declaration_type_name(set, decl, &block) end else enum_for :each_type_name end end |