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.
1343 1344 1345 1346 1347 |
# File 'lib/rbs/types.rb', line 1343 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.
1340 1341 1342 |
# File 'lib/rbs/types.rb', line 1340 def required @required end |
#self_type ⇒ Object (readonly)
Returns the value of attribute self_type.
1341 1342 1343 |
# File 'lib/rbs/types.rb', line 1341 def self_type @self_type end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1339 1340 1341 |
# File 'lib/rbs/types.rb', line 1339 def type @type end |
Instance Method Details
#==(other) ⇒ Object
1349 1350 1351 1352 1353 1354 |
# File 'lib/rbs/types.rb', line 1349 def ==(other) other.is_a?(Block) && other.type == type && other.required == required && other.self_type == self_type end |
#map_type(&block) ⇒ Object
1374 1375 1376 1377 1378 1379 1380 |
# File 'lib/rbs/types.rb', line 1374 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
1364 1365 1366 1367 1368 1369 1370 1371 1372 |
# File 'lib/rbs/types.rb', line 1364 def sub(s) return self if s.empty? self.class.new( type: type.sub(s), required: required, self_type: self_type&.sub(s) ) end |
#to_json(state = _ = nil) ⇒ Object
1356 1357 1358 1359 1360 1361 1362 |
# File 'lib/rbs/types.rb', line 1356 def to_json(state = _ = nil) { type: type, required: required, self_type: self_type }.to_json(state) end |