class RBI::TStructField

Attributes

default[RW]
name[RW]
type[RW]

Public Class Methods

new(name, type, default: nil, loc: nil, comments: []) click to toggle source
Calls superclass method RBI::NodeWithComments::new
# File lib/rbi/model.rb, line 1041
def initialize(name, type, default: nil, loc: nil, comments: [])
  super(loc: loc, comments: comments)
  @name = name
  @type = type
  @default = default
end

Public Instance Methods

accept_printer(v) click to toggle source
# File lib/rbi/printer.rb, line 642
def accept_printer(v)
  previous_node = v.previous_node
  v.printn if previous_node && (!previous_node.oneline? || !oneline?)

  v.printl("# #{loc}") if loc && v.print_locs
  v.visit_all(comments)
  case self
  when TStructProp
    v.printt("prop")
  when TStructConst
    v.printt("const")
  end
  v.print(" :#{name}, #{type}")
  default = self.default
  v.print(", default: #{default}") if default
  v.printn
end
compatible_with?(other) click to toggle source
# File lib/rbi/rewriters/merge_trees.rb, line 497
def compatible_with?(other)
  other.is_a?(TStructField) && name == other.name && type == other.type && default == other.default
end
fully_qualified_names() click to toggle source
# File lib/rbi/model.rb, line 1049
def fully_qualified_names; end