Module: RbsRails::Util
Constant Summary collapse
- MODULE_NAME =
Module.instance_method(:name)
Instance Method Summary collapse
Instance Method Details
#format_rbs(rbs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbs_rails/util.rb', line 18 def format_rbs(rbs) decls = if Gem::Version.new('3') <= Gem::Version.new(RBS::VERSION) # TODO: Remove this type annotation when rbs_rails depends on RBS v3 # @type var parsed: [RBS::Buffer, untyped, RBS::Declarations::t] parsed = _ = RBS::Parser.parse_signature(rbs) parsed[1] + parsed[2] else RBS::Parser.parse_signature(rbs) end StringIO.new.tap do |io| RBS::Writer.new(out: io).write(decls) end.string end |
#module_name(mod) ⇒ Object
8 9 10 11 |
# File 'lib/rbs_rails/util.rb', line 8 def module_name(mod) # HACK: RBS doesn't have UnboundMethod#bind_call (_ = MODULE_NAME).bind_call(mod) end |