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.
1288 1289 1290 1291 1292 |
# File 'lib/rbs/types.rb', line 1288 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.
1285 1286 1287 |
# File 'lib/rbs/types.rb', line 1285 def required @required end |
#self_type ⇒ Object (readonly)
Returns the value of attribute self_type.
1286 1287 1288 |
# File 'lib/rbs/types.rb', line 1286 def self_type @self_type end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1284 1285 1286 |
# File 'lib/rbs/types.rb', line 1284 def type @type end |
Instance Method Details
#==(other) ⇒ Object
1294 1295 1296 1297 1298 1299 |
# File 'lib/rbs/types.rb', line 1294 def ==(other) other.is_a?(Block) && other.type == type && other.required == required && other.self_type == self_type end |
#map_type(&block) ⇒ Object
1317 1318 1319 1320 1321 1322 1323 |
# File 'lib/rbs/types.rb', line 1317 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
1309 1310 1311 1312 1313 1314 1315 |
# File 'lib/rbs/types.rb', line 1309 def sub(s) self.class.new( type: type.sub(s), required: required, self_type: self_type&.sub(s) ) end |
#to_json(state = _ = nil) ⇒ Object
1301 1302 1303 1304 1305 1306 1307 |
# File 'lib/rbs/types.rb', line 1301 def to_json(state = _ = nil) { type: type, required: required, self_type: self_type }.to_json(state) end |