bamboo 0.1.1 → 0.2.0
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 +4 -4
- data/lib/bamboo.rb +1 -0
- data/lib/bamboo/constants.rb +13 -0
- data/lib/bamboo/grid.rb +22 -41
- data/lib/bamboo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0075ca7e247a179978c043788ea3e35f16cdcc1
|
4
|
+
data.tar.gz: d81e3e6d4131b25fb155ac08e462bf61a2f5ba58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 617880583897ea70ce8363bbce7779060907d330fd53c4f760c8c4bb21ec5701cb5f724c2ca696eb3c0874f72218374e0e954dce38d42ab65f129d16196d59e5
|
7
|
+
data.tar.gz: 0f39ffe8dbfbbaf80a3498c3e062c3f67b93ba87353c92dade3586268bda1dda1e6097395ad10ac2ad6120dcedaf087d42a4ad3583599149acceb01a5732de50
|
data/lib/bamboo.rb
CHANGED
data/lib/bamboo/grid.rb
CHANGED
@@ -1,55 +1,36 @@
|
|
1
1
|
module Bamboo
|
2
|
-
class Grid
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# for 5 columns:
|
9
|
-
# arrangement => [2, 3]
|
10
|
-
def uniform(arrangement = [])
|
11
|
-
width = []
|
12
|
-
single = @grid_width / Float(@columns)
|
13
|
-
|
14
|
-
if arrangement.empty?
|
15
|
-
@columns.times do
|
16
|
-
width.push single
|
17
|
-
end
|
18
|
-
else
|
19
|
-
arrangement.each do |c|
|
20
|
-
width.push c * single
|
21
|
-
end
|
22
|
-
end
|
2
|
+
class Grid
|
3
|
+
def self.uniform(columns = 12)
|
4
|
+
column_widths = []
|
5
|
+
single_width = Bamboo::TOTAL_WIDTH / Float(columns)
|
6
|
+
columns.times { |index| column_widths.push single_width * (index + 1) }
|
23
7
|
|
24
|
-
{
|
8
|
+
{ column_widths: column_widths, css: css(column_widths) }
|
25
9
|
end
|
26
10
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
11
|
+
def self.modular(columns = 2, scale = Bamboo::GOLDEN_RATIO)
|
12
|
+
column_widths = []
|
13
|
+
used_width = 0
|
14
|
+
available_width = Bamboo::TOTAL_WIDTH
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
width_previous = width_previous - width.last
|
36
|
-
sum = sum + width.last
|
16
|
+
columns.times do |index|
|
17
|
+
if index == columns - 1
|
18
|
+
column_widths.push available_width
|
37
19
|
else
|
38
|
-
width
|
20
|
+
width = available_width / scale
|
21
|
+
column_widths.push width
|
22
|
+
available_width = available_width - width
|
23
|
+
used_width = used_width + width
|
39
24
|
end
|
40
25
|
end
|
41
26
|
|
42
|
-
{
|
27
|
+
{ column_widths: column_widths, css: css(column_widths) }
|
43
28
|
end
|
44
29
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
css = ""
|
49
|
-
columns.each_with_index do |w,i|
|
50
|
-
css = css + ".col-#{i+1}{width:#{w}px}"
|
51
|
-
end
|
52
|
-
css
|
30
|
+
def self.css(columns)
|
31
|
+
css = columns.map.with_index { |width, index| ".col-#{index + 1}{width:#{width}%}" }
|
32
|
+
css.join
|
53
33
|
end
|
34
|
+
private_class_method :css
|
54
35
|
end
|
55
36
|
end
|
data/lib/bamboo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bamboo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashish Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- lib/bamboo.rb
|
73
|
+
- lib/bamboo/constants.rb
|
73
74
|
- lib/bamboo/grid.rb
|
74
75
|
- lib/bamboo/version.rb
|
75
76
|
homepage: https://github.com/ashishkumar/bamboo
|