Class: Steep::Interface::Shape
Defined Under Namespace
Classes: Entry, MethodOverload, Methods
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(type:, private:, methods: nil) ⇒ Shape
193
194
195
196
197
|
# File 'lib/steep/interface/shape.rb', line 193
def initialize(type:, private:, methods: nil)
@type = type
@private = private
@methods = methods || Methods.new(substs: [], methods: {})
end
|
Instance Attribute Details
Returns the value of attribute methods.
191
192
193
|
# File 'lib/steep/interface/shape.rb', line 191
def methods
@methods
end
|
Returns the value of attribute type.
190
191
192
|
# File 'lib/steep/interface/shape.rb', line 190
def type
@type
end
|
Instance Method Details
#private? ⇒ Boolean
218
219
220
|
# File 'lib/steep/interface/shape.rb', line 218
def private?
@private
end
|
#public? ⇒ Boolean
222
223
224
|
# File 'lib/steep/interface/shape.rb', line 222
def public?
!private?
end
|
#public_shape ⇒ Object
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/steep/interface/shape.rb', line 226
def public_shape
if public?
self
else
@public_shape ||= Shape.new(
type: type,
private: false,
methods: methods.public_methods
)
end
end
|
#subst(s, type: nil) ⇒ Object
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/steep/interface/shape.rb', line 207
def subst(s, type: nil)
ty =
if type
type
else
self.type.subst(s)
end
Shape.new(type: ty, private: private?, methods: methods.push_substitution(s))
end
|
199
200
201
|
# File 'lib/steep/interface/shape.rb', line 199
def to_s
"#<#{self.class.name}: type=#{type}, private?=#{@private}, methods={#{methods.each_name.sort.join(", ")}}"
end
|
#update(type: self.type, methods: self.methods) ⇒ Object
203
204
205
|
# File 'lib/steep/interface/shape.rb', line 203
def update(type: self.type, methods: self.methods)
_ = self.class.new(type: type, private: private?, methods: methods)
end
|