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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fab7d70e3eaa367a68f56fa6b7e88a9767762b80
4
- data.tar.gz: d1a9cb5f23f4011dccbf439875edfc7628273c8b
3
+ metadata.gz: b0075ca7e247a179978c043788ea3e35f16cdcc1
4
+ data.tar.gz: d81e3e6d4131b25fb155ac08e462bf61a2f5ba58
5
5
  SHA512:
6
- metadata.gz: 32a3f3fe32e0e84b880a4cc1bcdf84b17a9874a9167ab612ea6a5405952c958ebff2fd11bc80c4939031139b531e9b7ce879a9f4f24091243f27e46b2f9dd1af
7
- data.tar.gz: e9e38df569a8348b949c2f5686db2b86964cecbf06a0fa65edc9abab50b9f34e20d9b0301b2a4aac9e83a3fea9523d61d85c3cae15ce3e6d18029a0b6879ca30
6
+ metadata.gz: 617880583897ea70ce8363bbce7779060907d330fd53c4f760c8c4bb21ec5701cb5f724c2ca696eb3c0874f72218374e0e954dce38d42ab65f129d16196d59e5
7
+ data.tar.gz: 0f39ffe8dbfbbaf80a3498c3e062c3f67b93ba87353c92dade3586268bda1dda1e6097395ad10ac2ad6120dcedaf087d42a4ad3583599149acceb01a5732de50
@@ -1,2 +1,3 @@
1
1
  require "bamboo/version"
2
+ require "bamboo/constants"
2
3
  require "bamboo/grid"
@@ -0,0 +1,13 @@
1
+ module Bamboo
2
+ # GRID
3
+ TOTAL_WIDTH = 100
4
+
5
+ # MODULAR SCALES
6
+ MINOR_SECOND = 1.067
7
+ MAJOR_SECOND = 1.125
8
+ MINOR_THIRD = 1.200
9
+ PERFECT_FOURTH = 1.333
10
+ AUGMENTED_FOURTH = 1.414
11
+ PERFECT_FIGTH = 1.500
12
+ GOLDEN_RATIO = 1.618
13
+ end
@@ -1,55 +1,36 @@
1
1
  module Bamboo
2
- class Grid
3
- def initialize(grid_width = 960, columns = 2)
4
- @grid_width = grid_width
5
- @columns = columns
6
- end
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
- { grid_width: @grid_width, column_widths: width, css: css(width) }
8
+ { column_widths: column_widths, css: css(column_widths) }
25
9
  end
26
10
 
27
- def golden_ratio
28
- width = []
29
- width_previous = @grid_width # Start with full grid
30
- sum = 0
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
- @columns.times do |i|
33
- unless i == @columns - 1
34
- width.push width_previous / 1.61803398875
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.push @grid_width - sum
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
- { grid_width: @grid_width, column_widths: width, css: css(width) }
27
+ { column_widths: column_widths, css: css(column_widths) }
43
28
  end
44
29
 
45
- private
46
-
47
- def css(columns)
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
@@ -1,3 +1,3 @@
1
1
  module Bamboo
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
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-14 00:00:00.000000000 Z
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