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.



9
10
11
12
13
14
15
16
# File 'lib/flex_cocoa/cc_progress.rb', line 9

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.



8
9
10
# File 'lib/flex_cocoa/cc_progress.rb', line 8

def progress
  @progress
end

#totalObject (readonly)

Returns the value of attribute total.



8
9
10
# File 'lib/flex_cocoa/cc_progress.rb', line 8

def total
  @total
end

Instance Method Details

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/flex_cocoa/cc_progress.rb', line 18

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