Skip to content

Commit

Permalink
feat: convert weight and height to float
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Aug 30, 2019
1 parent bfb7a21 commit 32360b2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 69 deletions.
38 changes: 19 additions & 19 deletions src/components/WodParts.re
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ module Pounds = {

let make = kg =>
switch (kg) {
| 13 => 33.0
| 25 => 55.0
| _ => (kg->float_of_int *. approx)->round5
| 13.0 => 33.0
| 25.0 => 55.0
| _ => (kg *. approx)->round5
};
};

Expand All @@ -75,9 +75,9 @@ module Inches = {

let make = cm =>
switch (cm) {
| 60 => 24
| 45 => 20
| _ => (cm->float_of_int /. approx)->round5->int_of_float
| 60.0 => 24.0
| 45.0 => 20.0
| _ => (cm /. approx)->round5
};
};

Expand All @@ -86,8 +86,8 @@ let splitWeight = (~m, ~f, ~weight as w, ~system) =>
| Settings.Metric =>
switch (w) {
| `kg2(_) =>
str("(2*" ++ m->soi ++ "/" ++ f->soi ++ " " ++ weightUnit(w) ++ ")")
| _ => str("(" ++ m->soi ++ "/" ++ f->soi ++ " " ++ weightUnit(w) ++ ")")
str("(2*" ++ m->sof ++ "/" ++ f->sof ++ " " ++ weightUnit(w) ++ ")")
| _ => str("(" ++ m->sof ++ "/" ++ f->sof ++ " " ++ weightUnit(w) ++ ")")
}
| Settings.Imperial =>
switch (w) {
Expand All @@ -114,14 +114,14 @@ let splitWeight = (~m, ~f, ~weight as w, ~system) =>
| `cm(_) =>
str(
"("
++ m->Inches.make->soi
++ m->Inches.make->sof
++ "/"
++ f->Inches.make->soi
++ f->Inches.make->sof
++ " "
++ weightUnit(`inch)
++ ")",
)
| _ => str("(" ++ m->soi ++ "/" ++ f->soi ++ " " ++ weightUnit(w) ++ ")")
| _ => str("(" ++ m->sof ++ "/" ++ f->sof ++ " " ++ weightUnit(w) ++ ")")
}
};

Expand All @@ -131,15 +131,15 @@ let weightAndHeight =
| Settings.Metric =>
str(
"(2*"
++ maleWeight->soi
++ maleWeight->sof
++ "/"
++ femaleWeight->soi
++ femaleWeight->sof
++ " "
++ weightUnit(`kg(0))
++ " - "
++ maleHeight->soi
++ maleHeight->sof
++ "/"
++ femaleHeight->soi
++ femaleHeight->sof
++ " "
++ weightUnit(`cm(0))
++ ")",
Expand All @@ -153,9 +153,9 @@ let weightAndHeight =
++ " "
++ weightUnit(`lbs)
++ " - "
++ maleHeight->Inches.make->soi
++ maleHeight->Inches.make->sof
++ "/"
++ femaleHeight->Inches.make->soi
++ femaleHeight->Inches.make->sof
++ " "
++ weightUnit(`inch)
++ ")",
Expand All @@ -165,8 +165,8 @@ let weightAndHeight =

let singleWeight = (~m, ~weight as w) =>
switch (w) {
| `kg2(_) => str("(2*" ++ m->soi ++ " " ++ weightUnit(w) ++ ")")
| _ => str("(" ++ m->soi ++ " " ++ weightUnit(w) ++ ")")
| `kg2(_) => str("(2*" ++ m->sof ++ " " ++ weightUnit(w) ++ ")")
| _ => str("(" ++ m->sof ++ " " ++ weightUnit(w) ++ ")")
};

module Weight = {
Expand Down
8 changes: 4 additions & 4 deletions src/models/Weight.re
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type t = [
| `kg(int)
| `kg2(int)
| `kg(float)
| `kg2(float)
| `bodyweight
| `cm(int)
| `kg2cm(int, int)
| `cm(float)
| `kg2cm(float, float)
];
Loading

0 comments on commit 32360b2

Please sign in to comment.