class RBI::Struct
Attributes
keyword_init[RW]
members[RW]
name[RW]
Public Class Methods
new(name, members: [], keyword_init: false, loc: nil, comments: [], &block)
click to toggle source
Calls superclass method
RBI::Tree::new
# File lib/rbi/model.rb, line 275 def initialize(name, members: [], keyword_init: false, loc: nil, comments: [], &block) super(loc: loc, comments: comments) {} @name = name @members = members @keyword_init = keyword_init block&.call(self) end
Public Instance Methods
compatible_with?(other)
click to toggle source
# File lib/rbi/rewriters/merge_trees.rb, line 366 def compatible_with?(other) other.is_a?(Struct) && members == other.members && keyword_init == other.keyword_init end
fully_qualified_name()
click to toggle source
# File lib/rbi/model.rb, line 284 def fully_qualified_name return name if name.start_with?("::") "#{parent_scope&.fully_qualified_name}::#{name}" end
print_header(v)
click to toggle source
# File lib/rbi/printer.rb, line 254 def print_header(v) v.printt("#{name} = ::Struct.new") if !members.empty? || keyword_init v.print("(") args = members.map { |member| ":#{member}" } args << "keyword_init: true" if keyword_init v.print(args.join(", ")) v.print(")") end if empty? v.printn else v.printn(" do") end end