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.
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
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
235 236 237 |
# File 'lib/steep/interface/method_type.rb', line 235 def optional @optional end |
#type ⇒ Object (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
250 251 252 |
# File 'lib/steep/interface/method_type.rb', line 250 def closed? type.closed? end |
#free_variables ⇒ Object
261 262 263 |
# File 'lib/steep/interface/method_type.rb', line 261 def free_variables type.free_variables end |
#optional? ⇒ 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_s ⇒ Object
265 266 267 |
# File 'lib/steep/interface/method_type.rb', line 265 def to_s "#{optional? ? "?" : ""}{ #{type.params} -> #{type.return_type} }" end |