123456789_123456789_123456789_123456789_123456789_

Class: RBS::Types::Block

Relationships & Source Files
Inherits: Object
Defined in: lib/rbs/types.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(type:, required:) ⇒ Block

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 960

def initialize(type:, required:)
  @type = type
  @required = required ? true : false
end

Instance Attribute Details

#required (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 958

attr_reader :required

#type (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 957

attr_reader :type

Instance Method Details

#==(other)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 965

def ==(other)
  other.is_a?(Block) &&
    other.type == type &&
    other.required == required
end

#map_type(&block)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 985

def map_type(&block)
  Block.new(
    required: required,
    type: type.map_type(&block)
  )
end

#sub(s)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 978

def sub(s)
  self.class.new(
    type: type.sub(s),
    required: required
  )
end

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 971

def to_json(state = _ = nil)
  {
    type: type,
    required: required
  }.to_json(state)
end