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.
728 729 730 731 732 |
# File 'lib/rbs/types.rb', line 728 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.
726 727 728 |
# File 'lib/rbs/types.rb', line 726 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
725 726 727 |
# File 'lib/rbs/types.rb', line 725 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
724 725 726 |
# File 'lib/rbs/types.rb', line 724 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
734 735 736 |
# File 'lib/rbs/types.rb', line 734 def ==(other) other.is_a?(Param) && other.type == type && other.name == name end |
#hash ⇒ Object
740 741 742 |
# File 'lib/rbs/types.rb', line 740 def hash self.class.hash ^ type.hash ^ name.hash end |
#map_type(&block) ⇒ Object
744 745 746 747 748 749 750 |
# File 'lib/rbs/types.rb', line 744 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
752 753 754 |
# File 'lib/rbs/types.rb', line 752 def to_json(state = _ = nil) { type: type, name: name }.to_json(state) end |