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.



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

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

Instance Attribute Details

#optionalObject (readonly)

Returns the value of attribute optional.



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

def optional
  @optional
end

#typeObject (readonly)

Returns the value of attribute type.



234
235
236
# File 'lib/steep/interface/method_type.rb', line 234

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



246
247
248
# File 'lib/steep/interface/method_type.rb', line 246

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

#closed?Boolean

Returns:

  • (Boolean)


250
251
252
# File 'lib/steep/interface/method_type.rb', line 250

def closed?
  type.closed?
end

#free_variablesObject



261
262
263
# File 'lib/steep/interface/method_type.rb', line 261

def free_variables
  type.free_variables
end

#optional?Boolean

Returns:

  • (Boolean)


242
243
244
# File 'lib/steep/interface/method_type.rb', line 242

def optional?
  @optional
end

#subst(s) ⇒ Object



254
255
256
257
258
259
# File 'lib/steep/interface/method_type.rb', line 254

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

#to_sObject



265
266
267
# File 'lib/steep/interface/method_type.rb', line 265

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