Class: RBS::Types::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, required:) ⇒ Block

Returns a new instance of Block.



947
948
949
950
# File 'lib/rbs/types.rb', line 947

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

Instance Attribute Details

#requiredObject (readonly)

Returns the value of attribute required.



945
946
947
# File 'lib/rbs/types.rb', line 945

def required
  @required
end

#typeObject (readonly)

Returns the value of attribute type.



944
945
946
# File 'lib/rbs/types.rb', line 944

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



952
953
954
955
956
# File 'lib/rbs/types.rb', line 952

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

#map_type(&block) ⇒ Object



972
973
974
975
976
977
# File 'lib/rbs/types.rb', line 972

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

#sub(s) ⇒ Object



965
966
967
968
969
970
# File 'lib/rbs/types.rb', line 965

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

#to_json(state = _ = nil) ⇒ Object



958
959
960
961
962
963
# File 'lib/rbs/types.rb', line 958

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