Class: Steep::Interface::Block
- Inherits:
-
Object
- Object
- Steep::Interface::Block
- Defined in:
- lib/steep/interface/method_type.rb
Instance Attribute Summary collapse
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #closed? ⇒ Boolean
- #free_variables ⇒ Object
-
#initialize(type:, optional:) ⇒ Block
constructor
A new instance of Block.
- #optional? ⇒ Boolean
- #subst(s) ⇒ Object
- #to_s ⇒ Object
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
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
206 207 208 |
# File 'lib/steep/interface/method_type.rb', line 206 def optional @optional end |
#type ⇒ Object (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
221 222 223 |
# File 'lib/steep/interface/method_type.rb', line 221 def closed? type.closed? end |
#free_variables ⇒ Object
232 233 234 |
# File 'lib/steep/interface/method_type.rb', line 232 def free_variables type.free_variables end |
#optional? ⇒ 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_s ⇒ Object
236 237 238 |
# File 'lib/steep/interface/method_type.rb', line 236 def to_s "#{optional? ? "?" : ""}{ #{type.params} -> #{type.return_type} }" end |