Module: RubyBreaker::Runtime::TypeSigUnparser
- Includes:
- TypeDefs
- Defined in:
- lib/rubybreaker/runtime/typesig_unparser.rb
Overview
This module handles unparsing type signatures.
Constant Summary collapse
- DOCUMENTED =
This array lists monitored modules/classes that are outputed.
[]
Class Method Summary collapse
-
.pp_methods(pp, meth_type_map, opts = {}) ⇒ Object
Pretty prints type information for methods.
-
.pp_module(pp, mod, opts = {}) ⇒ Object
Pretty prints type information for the module/class.
-
.unparse(mod, opts = {}) ⇒ Object
This method unparses the type information in the specified module, displaying one or more type signatures for each method that is monitored during runtime.
Class Method Details
.pp_methods(pp, meth_type_map, opts = {}) ⇒ Object
Pretty prints type information for methods
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubybreaker/runtime/typesig_unparser.rb', line 17 def self.pp_methods(pp, meth_type_map, opts={}) meth_type_map.each { |meth_name, meth_type| case meth_type when MethodType pp.breakable() pp.text("typesig(\"") TypeUnparser.unparse_pp(pp, meth_type, opts) pp.text("\")") when MethodListType meth_type.types.each { |real_meth_type| pp.breakable() pp.text("typesig(\"") TypeUnparser.unparse_pp(pp, real_meth_type, opts) pp.text("\")") } else # Can't happen end } end |
.pp_module(pp, mod, opts = {}) ⇒ Object
Pretty prints type information for the module/class
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rubybreaker/runtime/typesig_unparser.rb', line 39 def self.pp_module(pp, mod, opts={}) # Skip it if we already have seen it return if DOCUMENTED.include?(mod) || mod.to_s[0..1] == "#<" # Remember that we have documented this module/class DOCUMENTED << mod # Get the method type mapping meth_type_map = Inspector.inspect_all(mod) # Check if this module is a class keyword = mod.instance_of?(Class) ? "class" : "module" pp.text("#{keyword} #{mod.to_s}", 80) pp.nest(2) do # See if there is any class method to show eigen = Runtime.eigen_class(mod) if !DOCUMENTED.include?(eigen) DOCUMENTED << eigen eigen_meth_type_map = Inspector.inspect_all(eigen) if eigen_meth_type_map.size > 0 pp.breakable() pp.text("class << self", 80) pp.nest(2) do self.pp_methods(pp, eigen_meth_type_map, :namespace => eigen) end pp.breakable() pp.text("end", 80) end end self.pp_methods(pp, meth_type_map, :namespace => mod) end pp.breakable() pp.text("end",80) pp.breakable() end |
.unparse(mod, opts = {}) ⇒ Object
This method unparses the type information in the specified module, displaying one or more type signatures for each method that is monitored during runtime.
81 82 83 84 85 86 87 |
# File 'lib/rubybreaker/runtime/typesig_unparser.rb', line 81 def self.unparse(mod, opts={}) str = "" pp = PrettyPrint.new(str) self.pp_module(pp, mod, opts) pp.flush return str end |