Module: Jejune::Options

Included in:
Main
Defined in:
lib/jejune/main.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debug_socketObject

Returns the value of attribute debug_socket.



41
42
43
# File 'lib/jejune/main.rb', line 41

def debug_socket
  @debug_socket
end

#encodingObject

the input encoding type; defaults to nil (currently, not used)



33
34
35
# File 'lib/jejune/main.rb', line 33

def encoding
  @encoding
end

#inputObject

the input stream used by the Main script; defaults to $stdin



35
36
37
# File 'lib/jejune/main.rb', line 35

def input
  @input
end

#interactiveObject

a boolean flag indicating whether or not to run the Main script in interactive mode; defaults to false



38
39
40
# File 'lib/jejune/main.rb', line 38

def interactive
  @interactive
end

#no_outputObject

Returns the value of attribute no_output.



39
40
41
# File 'lib/jejune/main.rb', line 39

def no_output
  @no_output
end

#profileObject

Returns the value of attribute profile.



40
41
42
# File 'lib/jejune/main.rb', line 40

def profile
  @profile
end

#ruby_profObject

Returns the value of attribute ruby_prof.



42
43
44
# File 'lib/jejune/main.rb', line 42

def ruby_prof
  @ruby_prof
end

Instance Method Details

#initialize(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/jejune/main.rb', line 44

def initialize( options = {} )
  @no_output    = options.fetch( :no_output, false )
  @profile      = options.fetch( :profile, false )
  @debug_socket = options.fetch( :debug_socket, false )
  @ruby_prof    = options.fetch( :ruby_prof, false )
  @encoding     = options.fetch( :encoding, nil )
  @interactive  = options.fetch( :interactive, false )
  @input        = options.fetch( :input, $stdin )
end

#parse_options(argv = ARGV) ⇒ Object

constructs an OptionParser and parses the argument list provided by argv



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/jejune/main.rb', line 55

def parse_options( argv = ARGV )
  oparser = OptionParser.new do | o |
    o.separator 'Input Options:'
    
    o.on( '-i', '--input "text to process"', doc( <<-END ) ) { |val| @input = val }
    | a string to use as direct input to the recognizer
    END
    
    o.on( '-I', '--interactive', doc( <<-END ) ) { @interactive = true }
    | run an interactive session with the recognizer
    END
  end
  
  setup_options( oparser )
  return oparser.parse( argv )
end