1#
2#   math-mode.rb -
3#   	$Release Version: 0.9.6$
4#   	$Revision: 38621 $
5#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
6#
7# --
8#
9#
10#
11require "mathn"
12
13module IRB
14  class Context
15    # Returns whether bc mode is enabled.
16    #
17    # See #math_mode=
18    attr_reader :math_mode
19    # Alias for #math_mode
20    alias math? math_mode
21
22    # Sets bc mode, which loads +lib/mathn.rb+ so fractions or matrix are
23    # available.
24    #
25    # Also available as the +-m+ command line option.
26    #
27    # See IRB@Command+line+options and the unix manpage <code>bc(1)</code> for
28    # more information.
29    def math_mode=(opt)
30      if @math_mode == true && !opt
31	IRB.fail CantReturnToNormalMode
32	return
33      end
34
35      @math_mode = opt
36      if math_mode
37	main.extend Math
38	print "start math mode\n" if verbose?
39      end
40    end
41
42    def inspect?
43      @inspect_mode.nil? && !@math_mode or @inspect_mode
44    end
45  end
46end
47
48