Module: RackConsole::ExprHelpers
- Included in:
- AppHelpers
- Defined in:
- lib/rack_console/expr_helpers.rb
Instance Method Summary collapse
- #expr_for_method(mod, name, kind) ⇒ Object
- #expr_for_module(obj) ⇒ Object
- #expr_for_object(obj, mod = nil, kind = nil) ⇒ Object
- #expr_for_object!(obj, mod = nil, kind = nil) ⇒ Object
Instance Method Details
#expr_for_method(mod, name, kind) ⇒ Object
33 34 35 |
# File 'lib/rack_console/expr_helpers.rb', line 33 def expr_for_method mod, name, kind mod.name && "#{expr_for_module(mod)}.#{kind}(#{name.to_sym.inspect})" end |
#expr_for_module(obj) ⇒ Object
37 38 39 |
# File 'lib/rack_console/expr_helpers.rb', line 37 def expr_for_module obj obj && obj.name && "::#{obj.name}" end |
#expr_for_object(obj, mod = nil, kind = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rack_console/expr_helpers.rb', line 16 def expr_for_object obj, mod = nil, kind = nil case obj when nil, true, false, ::Numeric, ::String obj.inspect when ::Time "Time.parse(#{obj.iso8601(6).inspect})" when ::Date "Date.parse(#{obj.to_s.inspect})" when ::Module expr_for_module obj when ::Method, ::UnboundMethod, MockMethod expr_for_method(mod, obj.name, kind) if mod && kind else nil end end |
#expr_for_object!(obj, mod = nil, kind = nil) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rack_console/expr_helpers.rb', line 7 def expr_for_object! obj, mod = nil, kind = nil @result = result_capture! do @expr = expr_for_object obj, mod, kind obj end @result_evaled = true @result_ok = true end |