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.
-
#self_type ⇒ Object
readonly
Returns the value of attribute self_type.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type:, required:, self_type: nil) ⇒ Block
constructor
A new instance of Block.
- #map_type(&block) ⇒ Object
- #sub(s) ⇒ Object
- #to_json(state = _ = nil) ⇒ Object
Constructor Details
#initialize(type:, required:, self_type: nil) ⇒ Block
Returns a new instance of Block.
1299 1300 1301 1302 1303 |
# File 'lib/rbs/types.rb', line 1299 def initialize(type:, required:, self_type: nil) @type = type @required = required ? true : false @self_type = self_type end |
Instance Attribute Details
#required ⇒ Object (readonly)
Returns the value of attribute required.
1296 1297 1298 |
# File 'lib/rbs/types.rb', line 1296 def required @required end |
#self_type ⇒ Object (readonly)
Returns the value of attribute self_type.
1297 1298 1299 |
# File 'lib/rbs/types.rb', line 1297 def self_type @self_type end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1295 1296 1297 |
# File 'lib/rbs/types.rb', line 1295 def type @type end |
Instance Method Details
#==(other) ⇒ Object
1305 1306 1307 1308 1309 1310 |
# File 'lib/rbs/types.rb', line 1305 def ==(other) other.is_a?(Block) && other.type == type && other.required == required && other.self_type == self_type end |
#map_type(&block) ⇒ Object
1328 1329 1330 1331 1332 1333 1334 |
# File 'lib/rbs/types.rb', line 1328 def map_type(&block) Block.new( required: required, type: type.map_type(&block), self_type: self_type ? yield(self_type) : nil ) end |
#sub(s) ⇒ Object
1320 1321 1322 1323 1324 1325 1326 |
# File 'lib/rbs/types.rb', line 1320 def sub(s) self.class.new( type: type.sub(s), required: required, self_type: self_type&.sub(s) ) end |
#to_json(state = _ = nil) ⇒ Object
1312 1313 1314 1315 1316 1317 1318 |
# File 'lib/rbs/types.rb', line 1312 def to_json(state = _ = nil) { type: type, required: required, self_type: self_type }.to_json(state) end |