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.



1024
1025
1026
1027
# File 'lib/rbs/types.rb', line 1024

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

Instance Attribute Details

#requiredObject (readonly)

Returns the value of attribute required.



1022
1023
1024
# File 'lib/rbs/types.rb', line 1022

def required
  @required
end

#typeObject (readonly)

Returns the value of attribute type.



1021
1022
1023
# File 'lib/rbs/types.rb', line 1021

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



1029
1030
1031
1032
1033
# File 'lib/rbs/types.rb', line 1029

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

#map_type(&block) ⇒ Object



1049
1050
1051
1052
1053
1054
# File 'lib/rbs/types.rb', line 1049

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

#sub(s) ⇒ Object



1042
1043
1044
1045
1046
1047
# File 'lib/rbs/types.rb', line 1042

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

#to_json(state = _ = nil) ⇒ Object



1035
1036
1037
1038
1039
1040
# File 'lib/rbs/types.rb', line 1035

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