Class: RBI::Visibility

Inherits:
NodeWithComments show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/rbi/model.rb,
lib/rbi/printer.rb

Overview

Visibility

Direct Known Subclasses

Private, Protected, Public

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#annotations, #merge_with, #oneline?

Methods inherited from Node

#compatible_with?, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string

Constructor Details

#initialize(visibility, loc: nil, comments: []) ⇒ Visibility

Returns a new instance of Visibility.



843
844
845
846
# File 'lib/rbi/model.rb', line 843

def initialize(visibility, loc: nil, comments: [])
  super(loc: loc, comments: comments)
  @visibility = visibility
end

Instance Attribute Details

#visibilityObject (readonly)

Returns the value of attribute visibility.



840
841
842
# File 'lib/rbi/model.rb', line 840

def visibility
  @visibility
end

Instance Method Details

#==(other) ⇒ Object



849
850
851
# File 'lib/rbi/model.rb', line 849

def ==(other)
  visibility == other.visibility
end

#accept_printer(v) ⇒ Object



549
550
551
552
553
554
555
# File 'lib/rbi/printer.rb', line 549

def accept_printer(v)
  print_blank_line_before(v)

  v.printl("# #{loc}") if loc && v.print_locs
  v.visit_all(comments)
  v.printl(visibility.to_s)
end

#private?Boolean

Returns:

  • (Boolean)


864
865
866
# File 'lib/rbi/model.rb', line 864

def private?
  visibility == :private
end

#protected?Boolean

Returns:

  • (Boolean)


859
860
861
# File 'lib/rbi/model.rb', line 859

def protected?
  visibility == :protected
end

#public?Boolean

Returns:

  • (Boolean)


854
855
856
# File 'lib/rbi/model.rb', line 854

def public?
  visibility == :public
end