class Steep::Interface::Shape
def initialize(type:, private:, methods: nil)
def initialize(type:, private:, methods: nil) @type = type @private = private @methods = methods || Methods.new(substs: [], methods: {}) end
def private?
def private? @private end
def public?
def public? !private? end
def public_shape
def public_shape if public? self else @public_shape ||= Shape.new( type: type, private: false, methods: methods.public_methods ) end end
def subst(s, type: nil)
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
def to_s
def to_s "#<#{self.class.name}: type=#{type}, private?=#{@private}, methods={#{methods.each_name.sort.join(", ")}}" end
def update(type: self.type, methods: self.methods)
def update(type: self.type, methods: self.methods) _ = self.class.new(type: type, private: private?, methods: methods) end