2002-07-09 07:17:17 -04:00
|
|
|
#
|
2009-03-05 22:56:38 -05:00
|
|
|
# math-mode.rb -
|
2009-07-07 07:36:20 -04:00
|
|
|
# $Release Version: 0.9.6$
|
2002-07-09 07:17:17 -04:00
|
|
|
# $Revision$
|
2005-04-13 11:27:09 -04:00
|
|
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
2002-07-09 07:17:17 -04:00
|
|
|
#
|
|
|
|
# --
|
|
|
|
#
|
2009-03-05 22:56:38 -05:00
|
|
|
#
|
2002-07-09 07:17:17 -04:00
|
|
|
#
|
|
|
|
require "mathn"
|
|
|
|
|
|
|
|
module IRB
|
|
|
|
class Context
|
2012-12-13 00:22:30 -05:00
|
|
|
# Returns whether bc mode is enabled.
|
|
|
|
#
|
|
|
|
# See #math_mode=
|
2002-07-09 07:17:17 -04:00
|
|
|
attr_reader :math_mode
|
2012-12-13 00:22:30 -05:00
|
|
|
# Alias for #math_mode
|
2002-07-09 07:17:17 -04:00
|
|
|
alias math? math_mode
|
|
|
|
|
2012-12-13 00:22:30 -05:00
|
|
|
# Sets bc mode, which loads +lib/mathn.rb+ so fractions or matrix are
|
|
|
|
# available.
|
|
|
|
#
|
|
|
|
# Also available as the +-m+ command line option.
|
|
|
|
#
|
|
|
|
# See IRB@Command+line+options and the unix manpage <code>bc(1)</code> for
|
|
|
|
# more information.
|
2002-07-09 07:17:17 -04:00
|
|
|
def math_mode=(opt)
|
2012-12-26 07:29:28 -05:00
|
|
|
if @math_mode == true && !opt
|
2003-02-07 14:00:21 -05:00
|
|
|
IRB.fail CantReturnToNormalMode
|
2002-07-09 07:17:17 -04:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
@math_mode = opt
|
|
|
|
if math_mode
|
|
|
|
main.extend Math
|
|
|
|
print "start math mode\n" if verbose?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect?
|
|
|
|
@inspect_mode.nil? && !@math_mode or @inspect_mode
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|