Browse Source

Update CHANGELOG and add few documentation lines

pull/1/head v0.1.3
Arthur POULET 5 years ago
parent
commit
e9d7cf9724
No known key found for this signature in database GPG Key ID: 7C42395DCA99B923
  1. 3
      CHANGELOG.md
  2. 2
      src/rollable/dice.cr
  3. 5
      src/rollable/dice/parse_wrap.cr
  4. 2
      src/rollable/die.cr
  5. 2
      src/rollable/fixed_value.cr

3
CHANGELOG.md

@ -1,5 +1,8 @@
# v0.1
## v0.1.3
- Minor improvements
## v0.1.2
- Block DOS attack in the parser

2
src/rollable/dice.cr

@ -3,6 +3,8 @@ require "./is_rollable"
require "./die"
require "./fixed_value"
# Not a front class. It is used to represent a tuple of die type and die amount
#
# A `Dice` is a amount of `Die`.
# It is rollable exactly like a classic `Die`
#

5
src/rollable/dice/parse_wrap.cr

@ -1,4 +1,5 @@
# coding: utf-8
class Rollable::Dice
# Returns the `Dice` and the string parsed from `str`, in a `NamedTuple`
# with "str" and "dice" keys.
@ -24,9 +25,11 @@ class Rollable::Dice
# Return a valid string parsed from `str`. (see `#parse_string`)
#
# Yields the `Dice` parsed from `str`.
#
# Then, it returns the string read.
# If strict is false, only the valid string is returned.
# ```
# Dice.parse("1d6") {|dice| dice.roll } => "1d6"
# ```
def self.parse(str : String, strict = true) : String
data = parse_string(str, strict)
yield data[:dice]

2
src/rollable/die.cr

@ -1,5 +1,7 @@
require "./is_rollable"
# Not a front class. It is used to represent a type of dice with faces
#
# A `Die` is a range of Integer values.
# It is rollable.
#

2
src/rollable/fixed_value.cr

@ -1,6 +1,6 @@
require "./die"
# Allow to create a die with a fixed value.
# Allows to create a die with a fixed value.
# The die will only gives this value everytime.
# (`.min`, `.max`, `.test`, `.average`)
#

Loading…
Cancel
Save