module
JosieHealth::LUT::CaffeineLUT
Defined in:
caffeine_lut.crConstant Summary
-
CATEGORY_DEFAULTS =
{"energy_drink" => {caffeine_mg: 160, default_ml: 500}, "energy_shot" => {caffeine_mg: 200, default_ml: 60}, "coffee" => {caffeine_mg: 95, default_ml: 240}, "tea" => {caffeine_mg: 50, default_ml: 240}, "soda" => {caffeine_mg: 40, default_ml: 355}} -
Category defaults
-
SERVING_SIZES =
{"can" => 355, "cans" => 355, "bottle" => 500, "bottles" => 500, "cup" => 240, "cups" => 240, "mug" => 350, "mugs" => 350, "shot" => 30, "shots" => 30} -
Serving sizes in ml
Class Method Summary
-
.all_brands : Array(String)
Get all brand names
-
.calculate_dose(dosage : String, substance : String) : NamedTuple(caffeine_mg: Float64, annotation: String) | Nil
Full caffeine dose calculation Input: dosage string, substance name Returns: {caffeine_mg, annotation} or nil
-
.calculate_mg(volume_ml : Float64, caffeine_per_serving : Int32, serving_ml : Int32) : Float64
Calculate caffeine mg from volume and brand info
-
.get_category_defaults(category : String) : NamedTuple(caffeine_mg: Int32, default_ml: Int32) | Nil
Get category defaults
-
.is_caffeine_source?(name : String) : Bool
Check if a substance is a caffeinated beverage/product
-
.load_data
Load caffeine data from embedded JSON
-
.lookup_brand(name : String) : NamedTuple(caffeine_mg: Int32, category: String, default_ml: Int32) | Nil
Lookup a brand by name (handles aliases)
-
.lookup_powder_mg_per_g(name : String) : Int32 | Nil
Lookup caffeine mg per gram for powder sources (e.g., matcha)
-
.parse_dosage(dosage : String) : NamedTuple(count: Int32, serving: String | Nil, volume_ml: Int32) | Nil
Parse dosage string like "2cans", "500ml", "1cup", "2g" Returns {count, serving_type, volume_ml} or nil if not parseable Note: for "g" serving, count is truncated to Int32; use the original dosage string for precise weight
-
.resolve_alias(name : String) : String
Resolve alias to canonical name
Class Method Detail
Full caffeine dose calculation Input: dosage string, substance name Returns: {caffeine_mg, annotation} or nil
Calculate caffeine mg from volume and brand info
Get category defaults
Check if a substance is a caffeinated beverage/product
Lookup a brand by name (handles aliases)
Lookup caffeine mg per gram for powder sources (e.g., matcha)
Parse dosage string like "2cans", "500ml", "1cup", "2g" Returns {count, serving_type, volume_ml} or nil if not parseable Note: for "g" serving, count is truncated to Int32; use the original dosage string for precise weight