Class: Rbs2ts::Converter::Types::Record

Inherits:
ConverterBase show all
Defined in:
lib/rbs2ts/converter/types.rb

Instance Method Summary collapse

Methods inherited from ConverterBase

#initialize

Constructor Details

This class inherits a constructor from Rbs2ts::Converter::Types::ConverterBase

Instance Method Details

#to_tsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rbs2ts/converter/types.rb', line 49

def to_ts
  field_lines = type.fields.map { |name, type|
    "#{Converter::Helper.convert_name(name)}: #{Types::Resolver.to_ts(type)};"
  }

  return '{}' if field_lines.empty?

  field_ts = field_lines.join("\n")

  ts = "  {\n  \#{Helper.indent(field_ts)}\n  }\n  CODE\n    \n  ts.chomp\nend\n"