Class: CcProgress

Inherits:
FlexCocoa show all
Defined in:
lib/flex_cocoa/cc_progress.rb

Instance Attribute Summary collapse

Attributes inherited from FlexCocoa

#exec, #output

Instance Method Summary collapse

Methods inherited from FlexCocoa

#button_response, #buttons_template, #parts_init, #post_initialize, set_path

Constructor Details

#initialize(title, message, total) ⇒ CcProgress

Returns a new instance of CcProgress.



5
6
7
8
9
10
11
12
# File 'lib/flex_cocoa/cc_progress.rb', line 5

def initialize (title, message, total)
  super()
  @base_message = message
  @progress = 0
  @total = total
  @exec << " progressbar --tile \"#{title}\" --text \"#{message}\""
  post_initialize
end

Instance Attribute Details

#progressObject (readonly)

Returns the value of attribute progress.



4
5
6
# File 'lib/flex_cocoa/cc_progress.rb', line 4

def progress
  @progress
end

#totalObject (readonly)

Returns the value of attribute total.



4
5
6
# File 'lib/flex_cocoa/cc_progress.rb', line 4

def total
  @total
end

Instance Method Details

#advance(message = nil, counter = true) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flex_cocoa/cc_progress.rb', line 14

def advance (message = nil, counter = true)
  @progress += 1
  output = "#{@progress / @total.to_f * 100}"

  if message.nil?
    output << " #{@base_message}"
  else
    output << " #{message}"
  end

  output << " (#{@progress}/#{@total})" if counter

  @stdin.puts output
end