Class: Frag::App
- Inherits:
-
Object
- Object
- Frag::App
- Defined in:
- lib/frag/app.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(args, input = STDIN, output = STDOUT, error = STDERR) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(args, input = STDIN, output = STDOUT, error = STDERR) ⇒ App
Returns a new instance of App.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/frag/app.rb', line 8 def initialize(args, input=STDIN, output=STDOUT, error=STDERR) @input, @output, @error = input, output, error @status = 0 @version_printed = false @state = State.new('frag:', 'frag end', '#', '', nil, nil) begin parser.parse!(args) rescue OptionParser::InvalidOption => e return error e. end args.size > 0 || @version_printed or return error "no files given" @input_paths = args end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
38 39 40 |
# File 'lib/frag/app.rb', line 38 def status @status end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/frag/app.rb', line 26 def run return @status if @status != 0 global_state = @state.dup @input_paths.each do |input_path| @state = global_state.dup manage_files(input_path) do |input, output| process(input, output) end end @status end |