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