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

#merge_with, #oneline?

Methods inherited from Node

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

Constructor Details

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

Returns a new instance of Visibility.



830
831
832
833
# File 'lib/rbi/model.rb', line 830

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.



827
828
829
# File 'lib/rbi/model.rb', line 827

def visibility
  @visibility
end

Instance Method Details

#==(other) ⇒ Object



836
837
838
# File 'lib/rbi/model.rb', line 836

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

#accept_printer(v) ⇒ Object



531
532
533
534
535
536
537
538
# File 'lib/rbi/printer.rb', line 531

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)
  v.printl(visibility.to_s)
end

#private?Boolean

Returns:

  • (Boolean)


851
852
853
# File 'lib/rbi/model.rb', line 851

def private?
  visibility == :private
end

#protected?Boolean

Returns:

  • (Boolean)


846
847
848
# File 'lib/rbi/model.rb', line 846

def protected?
  visibility == :protected
end

#public?Boolean

Returns:

  • (Boolean)


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

def public?
  visibility == :public
end