Class: RBS::MethodType::Block

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, required:) ⇒ Block

Returns a new instance of Block.



7
8
9
10
# File 'lib/rbs/method_type.rb', line 7

def initialize(type:, required:)
  @type = type
  @required = required
end

Instance Attribute Details

#requiredObject (readonly)

Returns the value of attribute required.



5
6
7
# File 'lib/rbs/method_type.rb', line 5

def required
  @required
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/rbs/method_type.rb', line 4

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
15
16
# File 'lib/rbs/method_type.rb', line 12

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

#sub(s) ⇒ Object



25
26
27
28
29
30
# File 'lib/rbs/method_type.rb', line 25

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

#to_json(*a) ⇒ Object



18
19
20
21
22
23
# File 'lib/rbs/method_type.rb', line 18

def to_json(*a)
  {
    type: type,
    required: required
  }.to_json(*a)
end