View Source LibJudge.Rule (lib_judge v0.4.8)
Defines the Rule
structure and provides methods for generating
and working with them
Summary
Functions
Creates a list of Rule
s referenced in a string
Creates a Rule
struct from a string
Turns a Rule
back into a string
Turns a Rule
back into a string
Types
@type rule_type() :: :category | :subcategory | :rule | :subrule
Functions
Creates a list of Rule
s referenced in a string
Examples
iex> LibJudge.Rule.all_from_string("See rules 702.21j and 702.108.")
{
:ok,
[
%LibJudge.Rule{type: :subrule, category: "7", subcategory: "02", rule: "21", subrule: "j"},
%LibJudge.Rule{type: :rule, category: "7", subcategory: "02", rule: "108", subrule: nil}
]
}
Creates a Rule
struct from a string
Examples
iex> LibJudge.Rule.from_string("702.21j")
{:ok, %LibJudge.Rule{type: :subrule, category: "7", subcategory: "02", rule: "21", subrule: "j"}}
Turns a Rule
back into a string
Non-bang variant
Examples
iex> LibJudge.Rule.to_string(%LibJudge.Rule{type: :category, category: "1"})
{:ok, "1."}
Turns a Rule
back into a string
Examples
iex> LibJudge.Rule.to_string!(%LibJudge.Rule{type: :subrule, category: "7", subcategory: "02", rule: "21", subrule: "j"})
"702.21j"