Class: RBS::Types::Block
- Inherits:
-
Object
- Object
- RBS::Types::Block
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type:, required:) ⇒ Block
constructor
A new instance of Block.
- #map_type(&block) ⇒ Object
- #sub(s) ⇒ Object
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(type:, required:) ⇒ Block
Returns a new instance of Block.
958 959 960 961 |
# File 'lib/rbs/types.rb', line 958 def initialize(type:, required:) @type = type @required = required ? true : false end |
Instance Attribute Details
#required ⇒ Object (readonly)
Returns the value of attribute required.
956 957 958 |
# File 'lib/rbs/types.rb', line 956 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
955 956 957 |
# File 'lib/rbs/types.rb', line 955 def type @type end |
Instance Method Details
#==(other) ⇒ Object
963 964 965 966 967 |
# File 'lib/rbs/types.rb', line 963 def ==(other) other.is_a?(Block) && other.type == type && other.required == required end |
#map_type(&block) ⇒ Object
983 984 985 986 987 988 |
# File 'lib/rbs/types.rb', line 983 def map_type(&block) Block.new( required: required, type: type.map_type(&block) ) end |
#sub(s) ⇒ Object
976 977 978 979 980 981 |
# File 'lib/rbs/types.rb', line 976 def sub(s) self.class.new( type: type.sub(s), required: required ) end |
#to_json(*a) ⇒ Object
969 970 971 972 973 974 |
# File 'lib/rbs/types.rb', line 969 def to_json(*a) { type: type, required: required }.to_json(*a) end |