Class: RBS::Types::Function::Param
- Inherits:
-
Object
- Object
- RBS::Types::Function::Param
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(type:, name:, location: nil) ⇒ Param
constructor
A new instance of Param.
- #map_type(&block) ⇒ Object
- #to_json(state = _ = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type:, name:, location: nil) ⇒ Param
Returns a new instance of Param.
856 857 858 859 860 |
# File 'lib/rbs/types.rb', line 856 def initialize(type:, name:, location: nil) @type = type @name = name @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
854 855 856 |
# File 'lib/rbs/types.rb', line 854 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
853 854 855 |
# File 'lib/rbs/types.rb', line 853 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
852 853 854 |
# File 'lib/rbs/types.rb', line 852 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
862 863 864 |
# File 'lib/rbs/types.rb', line 862 def ==(other) other.is_a?(Param) && other.type == type && other.name == name end |
#hash ⇒ Object
868 869 870 |
# File 'lib/rbs/types.rb', line 868 def hash self.class.hash ^ type.hash ^ name.hash end |
#map_type(&block) ⇒ Object
872 873 874 875 876 877 878 |
# File 'lib/rbs/types.rb', line 872 def map_type(&block) if block Param.new(name: name, type: yield(type), location: location) else enum_for :map_type end end |
#to_json(state = _ = nil) ⇒ Object
880 881 882 |
# File 'lib/rbs/types.rb', line 880 def to_json(state = _ = nil) { type: type, name: name }.to_json(state) end |
#to_s ⇒ Object
884 885 886 887 888 889 890 |
# File 'lib/rbs/types.rb', line 884 def to_s if name "#{type} #{name}" else "#{type}" end end |