class RBS::Template::Type
Attributes
c_constant_name[R]
The name of the C constant which stores the Ruby VALUE pointing to the generated class. e.g. ‘RBS_AST_Declarations_TypeAlias`
c_function_name[R]
The name of the pre-existing C function which constructs new Ruby objects of this type. e.g. ‘rbs_ast_declarations_typealias_new`
c_parent_constant_name[R]
The name of the C constant in which the ‘c_constant_name` is nested. e.g. `RBS_AST_Declarations`
c_type_name[R]
The name of the auto-generated C struct for this type, e.g. ‘rbs_ast_declarations_typealias_t`
fields[R]
ruby_class_name[R]
The name of the name of the auto-generated Ruby class for this type, e.g. ‘TypeAlias`
ruby_full_name[R]
The fully-qualified name of the auto-generated Ruby class for this type, e.g. ‘RBS::AST::Declarations::TypeAlias`
Public Class Methods
new(yaml)
click to toggle source
# File rbs-3.7.0/templates/template.rb, line 46 def initialize(yaml) @ruby_full_name = yaml["name"] @ruby_class_name = @ruby_full_name[/[^:]+\z/] # demodulize-like name = @ruby_full_name.gsub("::", "_") @c_function_name = name.gsub(/(^)?(_)?([A-Z](?:[A-Z]*(?=[A-Z_])|[a-z0-9]*))/) { ($1 || $2 || "_") + $3.downcase } # underscore-like @c_function_name.gsub!(/^rbs_types_/, 'rbs_') @c_function_name.gsub!(/^rbs_ast_declarations_/, 'rbs_ast_decl_') @c_constant_name = @ruby_full_name.gsub("::", "_") @c_parent_constant_name = @ruby_full_name.split("::")[0..-2].join("::").gsub("::", "_") @fields = yaml.fetch("fields", []).map { |field| Field.new(field) }.freeze end