Class: RBS::Types::Block
- Inherits:
-
Object
- Object
- RBS::Types::Block
- Includes:
- _ToJson
- Defined in:
- lib/rbs/types.rb,
sig/types.rbs
Instance Attribute Summary collapse
-
#location ⇒ loc?
readonly
Returns the value of attribute location.
-
#required ⇒ Boolean
readonly
Returns the value of attribute required.
-
#self_type ⇒ t?
readonly
Returns the value of attribute self_type.
-
#type ⇒ function
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(location: nil, type:, required:, self_type: nil) ⇒ Block
constructor
A new instance of Block.
- #map_type {|arg0| ... } ⇒ Block
- #sub(s) ⇒ Block
- #to_json(state = nil) ⇒ Object
Constructor Details
#initialize(location: nil, type:, required:, self_type: nil) ⇒ Block
Returns a new instance of Block.
1396 1397 1398 1399 1400 1401 |
# File 'lib/rbs/types.rb', line 1396 def initialize(location: nil, type:, required:, self_type: nil) @location = location @type = type @required = required ? true : false @self_type = self_type end |
Instance Attribute Details
#location ⇒ loc? (readonly)
Returns the value of attribute location.
1394 1395 1396 |
# File 'lib/rbs/types.rb', line 1394 def location @location end |
#required ⇒ Boolean (readonly)
Returns the value of attribute required.
1392 1393 1394 |
# File 'lib/rbs/types.rb', line 1392 def required @required end |
#self_type ⇒ t? (readonly)
Returns the value of attribute self_type.
1393 1394 1395 |
# File 'lib/rbs/types.rb', line 1393 def self_type @self_type end |
#type ⇒ function (readonly)
Returns the value of attribute type.
1391 1392 1393 |
# File 'lib/rbs/types.rb', line 1391 def type @type end |
Instance Method Details
#==(other) ⇒ Boolean
1403 1404 1405 1406 1407 1408 |
# File 'lib/rbs/types.rb', line 1403 def ==(other) other.is_a?(Block) && other.type == type && other.required == required && other.self_type == self_type end |
#map_type {|arg0| ... } ⇒ Block
1428 1429 1430 1431 1432 1433 1434 |
# File 'lib/rbs/types.rb', line 1428 def map_type(&block) Block.new( required: required, type: type.map_type(&block), self_type: self_type ? yield(self_type) : nil ) end |
#sub(s) ⇒ Block
1418 1419 1420 1421 1422 1423 1424 1425 1426 |
# File 'lib/rbs/types.rb', line 1418 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
1410 1411 1412 1413 1414 1415 1416 |
# File 'lib/rbs/types.rb', line 1410 def to_json(state = nil) { type: type, required: required, self_type: self_type }.to_json(state) end |