bootstrap_progressbar 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 292e340e27434f91a96c7aaf5ef7d1817d719908
4
- data.tar.gz: e4d7e48b911dd3da71eb6a90ec019fe1583d4168
3
+ metadata.gz: 268dd4c0b64651b82e1d4ab971b3da0989eb09b1
4
+ data.tar.gz: b645d9464c28e131d6e119257a6c57ab9ad5d85a
5
5
  SHA512:
6
- metadata.gz: 19b00b4f120da9d3244cf71e42b667b1fde2a64a7e48a6638719d264031346693f3d321da49c62552e9ebb8b435815b4a79f75cc0e0bf1842c0912d0b5768d1a
7
- data.tar.gz: 20d571c9f27b186755305c4df0ec109ab24a496aec63f2be8f5528aea80135c3715405683938e04c192c2f3b08ed44832a5bad20f82d0d08ae46de2724a5a85c
6
+ metadata.gz: 66a1e3985eeddf27feb2c1849cdb847c8478058d938d8c298ac1a293892006b79ea4c5076cc5c9df886824780e16ddc5da4342f83bd7a94f655524a615ebf065
7
+ data.tar.gz: de4c17fef798764ff99774415f4a5d5283f4c0658594a3ae2947a82bb7207e5cbea85de8f46fb92b185a71d388b4f540ce0ebbb641e0219534139120c59d8562
@@ -1,78 +1,80 @@
1
- module BootstrapProgressbar::Helper
2
- module Private
1
+ module BootstrapProgressbar
2
+ module Helper
3
+ module Private
3
4
 
4
- def self.check_percent(percent)
5
- if percent < 0 || percent > 1
6
- throw ArgumentError.new('the percent(first argument) should between 0 to 1')
5
+ def self.check_percent(percent)
6
+ if percent < 0 || percent > 1
7
+ throw ArgumentError.new('the percent(first argument) should between 0 to 1')
8
+ end
7
9
  end
8
- end
9
10
 
10
- # generate a bootstrap progress-bar with a percent and custom options
11
- # Params:
12
- # +percent+:: +Fixnum+ between 0 to 1.00
13
- # +options+::
14
- # alternative: ['success', 'danger', 'warning', 'info']
15
- # striped: boolean
16
- # active: boolean
17
- # label: boolean
18
- # class: a string contained more given class
19
- def self.only_progress_bar(percent, options = {})
20
- percent *= 100
21
- percent = percent.to_i
11
+ # generate a bootstrap progress-bar with a percent and custom options
12
+ # Params:
13
+ # +percent+:: +Fixnum+ between 0 to 1.00
14
+ # +options+::
15
+ # alternative: ['success', 'danger', 'warning', 'info']
16
+ # striped: boolean
17
+ # active: boolean
18
+ # label: boolean
19
+ # class: a string contained more given class
20
+ def self.only_progress_bar(percent, options = {})
21
+ percent *= 100
22
+ percent = percent.to_i
23
+
24
+ case options[:alternative]
25
+ when 'success'
26
+ alternative = 'progress-bar-success'
27
+ when 'danger'
28
+ alternative = 'progress-bar-danger'
29
+ when 'warning'
30
+ alternative = 'progress-bar-warning'
31
+ when 'info'
32
+ alternative = 'progress-bar-info'
33
+ else
34
+ alternative = ''
35
+ end
22
36
 
23
- case options[:alternative]
24
- when 'success'
25
- alternative = 'progress-bar-success'
26
- when 'danger'
27
- alternative = 'progress-bar-danger'
28
- when 'warning'
29
- alternative = 'progress-bar-warning'
30
- when 'info'
31
- alternative = 'progress-bar-info'
37
+ if options[:active]
38
+ striped = "progress-bar-striped active"
39
+ elsif options[:striped]
40
+ striped = "progress-bar-striped"
32
41
  else
33
- alternative = ''
34
- end
42
+ striped = ""
43
+ end
35
44
 
36
- if options[:active]
37
- striped = "progress-bar-striped active"
38
- elsif options[:striped]
39
- striped = "progress-bar-striped"
40
- else
41
- striped = ""
42
- end
45
+ clazz = options[:class] if options[:class]
43
46
 
44
- clazz = options[:class] if options[:class]
47
+ unless options[:label]
48
+ percent_and_label = "<span class='sr-only'>#{percent}%</span>"
49
+ else
50
+ percent_and_label = "#{percent}%"
51
+ end
45
52
 
46
- unless options[:label]
47
- percent_and_label = "<span class='sr-only'>#{percent}%</span>"
48
- else
49
- percent_and_label = "#{percent}%"
53
+ "<div class='#{[clazz, 'progress-bar', alternative, striped].join(' ').strip()}' role='progressbar' aria-valuenow='#{percent}' aria-valuemin='0' aria-valuemax='100' style='width: #{percent}%'>#{percent_and_label}</div>"
50
54
  end
51
55
 
52
- "<div class='#{[clazz, 'progress-bar', alternative, striped].join(' ').strip()}' role='progressbar' aria-valuenow='#{percent}' aria-valuemin='0' aria-valuemax='100' style='width: #{percent}%'>#{percent_and_label}</div>"
53
56
  end
54
57
 
55
- end
58
+ include Private
56
59
 
57
- include Private
60
+ # generate progress and progress-bar inside
61
+ def progress_bar(percent, options = {})
62
+ Private.check_percent(percent)
58
63
 
59
- # generate progress and progress-bar inside
60
- def progress_bar(percent, options = {})
61
- Private.check_percent(percent)
64
+ if options[:class]
65
+ clazz = options[:class]
66
+ options[:class] = ""
67
+ end
68
+ progress_bar = Private.only_progress_bar(percent, options)
62
69
 
63
- if options[:class]
64
- clazz = options[:class]
65
- options[:class] = ""
70
+ raw "<div class='#{[clazz, 'progress'].join(' ').strip()}'>#{progress_bar}</div>"
66
71
  end
67
- progress_bar = Private.only_progress_bar(percent, options)
68
72
 
69
- raw "<div class='#{[clazz, 'progress'].join(' ').strip()}'>#{progress_bar}</div>"
70
- end
73
+ # only generate the progress-bar
74
+ def simple_progress_bar(percent, options = {})
75
+ Private.check_percent(percent)
76
+ raw Private.only_progress_bar(percent, options)
77
+ end
71
78
 
72
- # only generate the progress-bar
73
- def simple_progress_bar(percent, options = {})
74
- Private.check_percent(percent)
75
- raw Private.only_progress_bar(percent, options)
76
79
  end
77
-
78
80
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapProgressbar
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_progressbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - spacewander