Class: Steep::Interface::Block

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, optional:) ⇒ Block

Returns a new instance of Block.



208
209
210
211
# File 'lib/steep/interface/method_type.rb', line 208

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

Instance Attribute Details

#optionalObject (readonly)

Returns the value of attribute optional.



206
207
208
# File 'lib/steep/interface/method_type.rb', line 206

def optional
  @optional
end

#typeObject (readonly)

Returns the value of attribute type.



205
206
207
# File 'lib/steep/interface/method_type.rb', line 205

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



217
218
219
# File 'lib/steep/interface/method_type.rb', line 217

def ==(other)
  other.is_a?(self.class) && other.type == type && other.optional == optional
end

#closed?Boolean

Returns:

  • (Boolean)


221
222
223
# File 'lib/steep/interface/method_type.rb', line 221

def closed?
  type.closed?
end

#free_variablesObject



232
233
234
# File 'lib/steep/interface/method_type.rb', line 232

def free_variables
  type.free_variables
end

#optional?Boolean

Returns:

  • (Boolean)


213
214
215
# File 'lib/steep/interface/method_type.rb', line 213

def optional?
  @optional
end

#subst(s) ⇒ Object



225
226
227
228
229
230
# File 'lib/steep/interface/method_type.rb', line 225

def subst(s)
  self.class.new(
    type: type.subst(s),
    optional: optional
  )
end

#to_sObject



236
237
238
# File 'lib/steep/interface/method_type.rb', line 236

def to_s
  "#{optional? ? "?" : ""}{ #{type.params} -> #{type.return_type} }"
end