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(state = _ = nil) ⇒ Object
Constructor Details
#initialize(type:, required:) ⇒ Block
Returns a new instance of Block.
959 960 961 962 |
# File 'lib/rbs/types.rb', line 959 def initialize(type:, required:) @type = type @required = required ? true : false end |
Instance Attribute Details
#required ⇒ Object (readonly)
Returns the value of attribute required.
957 958 959 |
# File 'lib/rbs/types.rb', line 957 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
956 957 958 |
# File 'lib/rbs/types.rb', line 956 def type @type end |
Instance Method Details
#==(other) ⇒ Object
964 965 966 967 968 |
# File 'lib/rbs/types.rb', line 964 def ==(other) other.is_a?(Block) && other.type == type && other.required == required end |
#map_type(&block) ⇒ Object
984 985 986 987 988 989 |
# File 'lib/rbs/types.rb', line 984 def map_type(&block) Block.new( required: required, type: type.map_type(&block) ) end |
#sub(s) ⇒ Object
977 978 979 980 981 982 |
# File 'lib/rbs/types.rb', line 977 def sub(s) self.class.new( type: type.sub(s), required: required ) end |
#to_json(state = _ = nil) ⇒ Object
970 971 972 973 974 975 |
# File 'lib/rbs/types.rb', line 970 def to_json(state = _ = nil) { type: type, required: required }.to_json(state) end |