INumberDef: Rounding version of NumberDef.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 16 Mar 2010 02:21:42 +0000 (19:21 -0700)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 16 Mar 2010 02:21:42 +0000 (19:21 -0700)
bulletml/__init__.py
bulletml/expr.py

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9dc15d1d5ce5743d4e98423bbe04605c05e72df9 100644 (file)
@@ -0,0 +1,6 @@
+"""BulletML parser.
+
+http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html
+"""
+
+from bulletml.parser import BulletML
index 80224760f2039f66397fa0a62d2eb53ac34bf606..9ca82ec128a98a369df1855f52aec7a86aefd47d 100644 (file)
@@ -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)))