simple_progress_bar 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a3e43646e00d639294ca703e689cd1fd041d49c
4
- data.tar.gz: cf7de545e2b2027971f5e1b6a7f6714397d69b57
3
+ metadata.gz: 2d738175b15062f8ad0c24c5ae021fd9eef7544a
4
+ data.tar.gz: d72e119a2d786cc857bad709c1a64e062a6ea93a
5
5
  SHA512:
6
- metadata.gz: 2a5ff35cea68582a95a92108116588a6caafda3ce75dbb6859772601b066141af4d80bede36f2abd74b665b8154f5d853b9e9ac22110bd15a202d6d586b3cb2a
7
- data.tar.gz: e96dc4064b720bd12972682ff180a3ad85d3bfbf6592ea59e752f6f6005b11f850bd2abdfe0073245e927a7f396eeaf562bcfb5feaec51949578041537c74ad8
6
+ metadata.gz: d24f70841ce63d5cca466b37bb7362eb78f3c9ad8deb9ac8cf2bbd845200c2537025250a6ed6c685425f02410ec080a76db66ad837044eb81a2270a0f5671106
7
+ data.tar.gz: aa0da172d63313e528637673aff95acd48e8839fad2925078eb2f4c52a5a061c7df09fd79a8acf49a917c41e81d821d0ed9f060148cf513a74730f8593a02634
@@ -1,13 +1,13 @@
1
1
  # the SimpleProgressBar class
2
2
  module SimpleProgressBar
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.2"
4
4
  # Constructor
5
5
  def initialize(max = 100.0)
6
- @max ||= max #will set the default value only if it's nil
7
- @current ||= 0.0
8
- @percentage ||= 0.0
9
- @start_time = nil
10
- @previous_time = nil
6
+ self.max ||= max #will set the default value only if it's nil
7
+ self.current ||= 0.0
8
+ self.percentage ||= 0.0
9
+ self.start_time = nil
10
+ self.previous_time = nil
11
11
  end
12
12
 
13
13
  attr_accessor :max, :current, :percentage, :start_time, :previous_time
@@ -18,7 +18,7 @@ module SimpleProgressBar
18
18
  # * *Arguments* :
19
19
  # - max -> value should be greater 0, will be parsed to float
20
20
  def set_max(max)
21
- @max = (max > 0 ? max : 1)
21
+ self.max = (max > 0 ? max : 1)
22
22
  end
23
23
 
24
24
  # The increment function adds to the current progress value
@@ -27,23 +27,23 @@ module SimpleProgressBar
27
27
  # * *Arguments* :
28
28
  # - amount -> value which will be added to the current progress
29
29
  def increment(amount = 1)
30
- @start_time ||= Time.now
31
- @current = (@current + amount < @max ? @current + amount : @max)
32
- @previous_time ||= Time.now
30
+ self.start_time ||= Time.now
31
+ self.current = (self.current + amount < self.max ? self.current + amount : self.max)
32
+ self.previous_time ||= Time.now
33
33
  calc_percent
34
34
  end
35
35
 
36
36
  # The time_to_finish method calculates the secondes needed to finish
37
37
  # based on the average time between increments
38
38
  def time_to_finish
39
- past_time = Time.now - @start_time
40
- seconds_to_go = past_time * @max / @current - past_time
39
+ past_time = Time.now - self.start_time
40
+ seconds_to_go = past_time * self.max / self.current - past_time
41
41
  puts "time to go: #{seconds_to_go.round}s"
42
42
  end
43
43
 
44
44
  # Inspect function to show the object and the current/max for easy debugging
45
45
  def inspect
46
- "#<SimpleProgressBar:#{@current}/#{@max}>"
46
+ "#<SimpleProgressBar:#{self.current}/#{self.max}>"
47
47
  end
48
48
 
49
49
  private
@@ -51,6 +51,6 @@ module SimpleProgressBar
51
51
  # The percent function calculates the percentage
52
52
  # This method is called before every update, so it will be up to date
53
53
  def calc_percent
54
- @percentage = (@current <= @max ? @current/@max*100 : @max)
54
+ self.percentage = (self.current <= self.max ? self.current/self.max*100 : self.max)
55
55
  end
56
56
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "simple_progress_bar"
7
- spec.version = "0.1.1"
7
+ spec.version = "0.1.2"
8
8
  spec.authors = ["iPet"]
9
9
  spec.email = ["patrick-salij@hotmail.com"]
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_progress_bar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - iPet