Module: RbsRails::Util
Constant Summary collapse
- MODULE_NAME =
Module.instance_method(:name)
Instance Method Summary collapse
Instance Method Details
#format_rbs(rbs) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rbs_rails/util.rb', line 13 def format_rbs(rbs) decls = if Gem::Version.new('3') <= Gem::Version.new(RBS::VERSION) parsed = _ = RBS::Parser.parse_signature(rbs) parsed[1] + parsed[2] else # TODO: Remove this type annotation when rbs_rails drops support of RBS 2.x. # @type var parsed: [RBS::Declarations::t] parsed = _ = RBS::Parser.parse_signature(rbs) end StringIO.new.tap do |io| RBS::Writer.new(out: io).write(decls) end.string end |
#module_name(mod, abs: true) ⇒ Object
7 8 9 10 11 |
# File 'lib/rbs_rails/util.rb', line 7 def module_name(mod, abs: true) name = MODULE_NAME.bind_call(mod) name ="::#{name}" if abs name end |