bra 1.0.1

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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/bin/bra +22 -0
  3. data/data/BRA-CHART.csv +15 -0
  4. data/lib/bra.rb +89 -0
  5. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 98b1cead7af18eb9bd659a41901ee2f89e7e5068
4
+ data.tar.gz: 5fbd2a0d32c8ed791fe8143b1db79b321f28b405
5
+ SHA512:
6
+ metadata.gz: 12e8aa86a681bcd21609b4cca6d7e6c1270f631bb3bfc3285843cbac986391ef4883b4b623561003be14cb06c584976a6aae7652893042a526180739c15ccb45
7
+ data.tar.gz: 7e791900bd2665bc49db5cb71fd65316fbc54cc41198a9b9ac91bdb52e1c454b338ca0b9fcc57bb5235907827df5ac8cff49e9e9389983b6308b3e8ba4ff1d08
data/bin/bra ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bra"
4
+
5
+ # Caller for Bra module
6
+ #
7
+ underbust = ARGV[0]
8
+ bust = ARGV[1]
9
+ unit = ARGV[2]
10
+ country = ARGV[3] || 'us'
11
+ if ARGV.size < 3
12
+ puts "HELP: ruby bra.rb UNDERBUST BUST UNIT [COUNTRY]"
13
+ puts "HELP: Example: ruby bra.rb 83 102.6 cm"
14
+ puts "HELP: Example: ruby bra.rb 35.1 41.5 inch"
15
+ puts "HELP: Example: ruby bra.rb 35.1 41.5 inch eu"
16
+ puts "HELP: Example: ruby bra.rb 83 102 inch fr"
17
+ else
18
+ include Bra
19
+ puts Bra.computer(underbust, bust, unit, country)
20
+ end
21
+
22
+
@@ -0,0 +1,15 @@
1
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
+ Underbust_down)/Bust_across;0-28.6;28.7-29.4;29.5-30.4;30.5-31.4;31.5-32.4;32.5-33.4;33.5-34.4;34.5-35.4;35.5-36.4;36.5-37.4;37.5-38.4;38.5-39.4;39.5-40.4;40.5-41.4;41.5-42.4;42.5-43.4;43.5-44.4;44.5-45.4;45.5-46.4;46.5-47.4;47.5-48.4;48.5-49.4;49.5-50.4;50.5-51.4;51.5-52.4;52.5-53.4;53.5-54.4;54.5-55.4;55.5-56.4;56.5-57.4;57.5-58.4
3
+ 26.5-28.4;28AA;28A;28B;28C;28D;28DD/E;28DDD;28G;28H;28I;28J;28K;28L;28M;28N;28O;;;;;;;;;;;;;;;
4
+ 28.5-30.4;—;—;30AA;30A;30B;30C;30D;30DD;30DDD;30G;30H;30I;30J;30K;30L;30M;;;;;;;;;;;;;;;
5
+ 30.5-32.4;—;—;—;—;32AA;32A;32B;32C;32D;32DD;32DDD;32G;32H;32I;32J;32K;;;;;;;;;;;;;;;
6
+ 32.5-34.4;—;—;—;—;—;—;34AA;34A;34B;34C;34D;34DD;34DDD;34G;34H;34I;;;;;;;;;;;;;;;
7
+ 34.5-36.4;—;—;—;—;—;—;—;—;36AA;36A;36B;36C;36D;36DD;36DDD;36G;;;;;;;;;;;;;;;
8
+ 36.5-38.4;—;—;—;—;—;—;—;—;—;—;38AA;38A;38B;38C;38D;38DD;;;;;;;;;;;;;;;
9
+ 38.5-40.4;—;—;—;—;—;—;—;—;—;—;—;—;40AA;40A;40B;40C;40D;40DD;40DDD;40G;40H;40I;40J;40K;40L;40M;40N;40O;40P;—;—
10
+ 40.5-42.4;;;;;;;;;;;;;;;;42A;42B;42C;42D;42DD;42DDD;42G;42H;42I;42J;42K;42L;42M;42N;42O;42P
11
+ 42.5-44.4;;;;;;;;;;;;;;;;—;—;44A;44B;44C;44D;44DD;44DDD;44G;44H;44I;44J;44K;44L;44M;44N
12
+ 44.5-46.4;;;;;;;;;;;;;;;;—;—;—;—;46A;46B;46C;46D;46DD;46DDD;46G;46H;46I;46J;46K;46L
13
+ 46.5-48.4;;;;;;;;;;;;;;;;—;—;—;—;—;—;48A;48B;48C;48D;48DD;48DDD;48G;48H;48I;48J
14
+ 48.5-50.4;;;;;;;;;;;;;;;;—;—;—;—;—;—;—;—;50A;50B;50C;50D;50DD;50DDD;50G;50H
15
+ 50.5-52.4;;;;;;;;;;;;;;;;—;—;—;—;—;—;—;—;—;—;52A;52B;52C;52D;52DD;52DDD
data/lib/bra.rb ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # author: Hanine HAMZIOUI BEN MADANI <hanynowsky@gmail.com>
4
+ # December 2017
5
+ # Module that computes Bra size based on underbust and bust measurements
6
+
7
+ require 'csv'
8
+ module Bra
9
+ @debug = false
10
+ puts `ruby --version` if @debug
11
+ @matrix = Dir.pwd + '/data/BRA-CHART.csv'
12
+ @matrix = 'BRA-CHART.csv' unless File.file?(@matrix)
13
+ @cup = '00A'
14
+
15
+ # Convert Centimeters to inches
16
+ def self.cm_to_inch(cms)
17
+ return (cms.to_f / 2.54).round(2)
18
+ end
19
+
20
+ # Cup Converter - Correspondance between US,FR and EU
21
+ def self.cup_converter(cup, country)
22
+ @underbust = {
23
+ "50" => {"fr"=>"130", "eu"=>"115"},
24
+ "48" => {"fr"=>"125", "eu"=>"110"},
25
+ "46" => {"fr"=>"120", "eu"=>"105"},
26
+ "44" => {"fr"=>"115", "eu"=>"100"},
27
+ "42" => {"fr"=>"110", "eu"=>"95"},
28
+ "40" => {"fr"=>"105", "eu"=>"90"},
29
+ "38" => {"fr"=>"100", "eu"=>"85"},
30
+ "36" => {"fr"=>"95", "eu"=>"80"},
31
+ "34" => {"fr"=>"90", "eu"=>"75"},
32
+ "32" => {"fr"=>"85", "eu"=>"70"},
33
+ "30" => {"fr"=>"90", "eu"=>"65"},
34
+ "28" => {"fr"=>"75", "eu"=>"60"},
35
+ "26" => {"fr"=>"70", "eu"=>"55"},
36
+ "24" => {"fr"=>"65", "eu"=>"50"}
37
+ }
38
+ country = country.downcase
39
+ ubust = cup.gsub(/[^0-9]/, '').to_i
40
+ cup = cup.gsub(/\d+/, "").squeeze(" ").strip
41
+ fr = @underbust["#{ubust}"]['fr']
42
+ eu = @underbust["#{ubust}"]['eu']
43
+ us = ubust
44
+ cup = 'F' if cup.include?('DDD')
45
+ cup = 'E' if cup =~ /^[D][D]$/
46
+ return "#{fr}#{cup}" if country == 'fr' or country == 'france'
47
+ return "#{eu}#{cup}" if country == 'eu' or country == 'europe'
48
+ return "#{ubust}#{cup}"
49
+ rescue => e
50
+ puts "#{e.message}" if @debug
51
+ return @cup
52
+ end
53
+
54
+ # Compute Bra Size
55
+ def self.computer(ubust, bust, unit='inch', country='us')
56
+ if unit == 'cm'
57
+ ubust = cm_to_inch(ubust.to_f)
58
+ bust = cm_to_inch(bust.to_f)
59
+ end
60
+ bust_idx = 0
61
+ # Spot the bust cell
62
+ CSV.foreach(@matrix, quote_char: '"', col_sep: ';', row_sep: :auto, headers: true) do |row|
63
+ row.each_with_index do |cell, idx|
64
+ bust_min = cell[1].split("-")[0].to_f.round(2)
65
+ bust_max = cell[1].split("-")[1].to_f.round(1)
66
+ if bust.to_f >= bust_min and bust.to_f <= bust_max
67
+ bust_idx = idx
68
+ puts "#{idx}: #{bust_min} #{bust_max}" if @debug
69
+ end
70
+ end
71
+ puts "\n" if @debug
72
+ break
73
+ end
74
+ # Spot the underbust cell and correspond with bust index
75
+ CSV.foreach(@matrix, quote_char: '"', col_sep: ';', row_sep: :auto, headers: true) do |row|
76
+ ubust_min = row[0].split("-")[0].to_f.round(2)
77
+ ubust_max = row[0].split("-")[1].to_f.round(1)
78
+ if ubust.to_f >= ubust_min and ubust.to_f <= ubust_max
79
+ puts "#{ubust_min} #{ubust_max}" if @debug
80
+ puts row[bust_idx] if @debug
81
+ @cup = row[bust_idx]
82
+ end
83
+ end
84
+ return cup_converter(@cup, country)
85
+ rescue => e
86
+ puts "Error: #{e.message}"
87
+ return @cup
88
+ end
89
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bra
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hanine HAMZIOUI BEN MADANI
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Bra size calculator, based on measurements of underbust and bust circumference
14
+ email: hanynowsky@gmail.com
15
+ executables:
16
+ - bra
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/bra
21
+ - data/BRA-CHART.csv
22
+ - lib/bra.rb
23
+ homepage: http://rubygems.org/gems/bra
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.5.1
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Bra Size computer
47
+ test_files: []