From 3674933e0881e379e9945f5477cbef187abfc871 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Mon, 15 Mar 2010 19:21:42 -0700 Subject: [PATCH] INumberDef: Rounding version of NumberDef. --- bulletml/__init__.py | 6 ++++++ bulletml/expr.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/bulletml/__init__.py b/bulletml/__init__.py index e69de29..9dc15d1 100644 --- a/bulletml/__init__.py +++ b/bulletml/__init__.py @@ -0,0 +1,6 @@ +"""BulletML parser. + +http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html +""" + +from bulletml.parser import BulletML diff --git a/bulletml/expr.py b/bulletml/expr.py index 8022476..9ca82ec 100644 --- a/bulletml/expr.py +++ b/bulletml/expr.py @@ -62,3 +62,8 @@ class NumberDef(object): def __repr__(self): return "%s(%r)" % (type(self).__name__, self.__original) + +class INumberDef(NumberDef): + """A NumberDef, but returns rounded integer results.""" + def __call__(self, params, rank): + return int(round(super(INumberDef, self).__call__(params, rank))) -- 2.30.2