Sha256: 3dea4a6fd720d168417ede49b1ac7381fcd5e8f6a7c73900376b7c3cc966454b
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
module Steep module TypeName class Base attr_reader :name def initialize(name:) @name = name end def ==(other) other.is_a?(self.class) && other.name == name end def hash self.class.hash ^ name.hash end alias eql? == def to_s name.to_s end def map_module_name self.class.new(name: yield(name)) end end class Interface < Base def map_module_name self end end class Class < Base attr_reader :constructor def to_s k = case constructor when nil "" when true " constructor" when false " noconstructor" end "#{name}.class#{k}" end def initialize(name:, constructor:) super(name: name) @constructor = constructor end def ==(other) other.is_a?(self.class) && other.name == name && other.constructor == constructor end def hash self.class.hash ^ name.hash ^ constructor.hash end NOTHING = Object.new def updated(constructor: NOTHING) if NOTHING == constructor constructor = self.constructor end self.class.new(name: name, constructor: constructor) end def map_module_name self.class.new(name: yield(name), constructor: constructor) end end class Module < Base def to_s "#{name}.module" end end class Instance < Base; end class Alias < Base def map_module_name self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
steep-0.5.1 | lib/steep/type_name.rb |
steep-0.5.0 | lib/steep/type_name.rb |