Permalink
Browse files

Implement RandomNumber LazyNum

  • Loading branch information...
rgascons committed Jul 25, 2015
1 parent e150429 commit 5c183f8dea0adfe9072f28147abfbeb4e27ec99f
Showing with 10 additions and 0 deletions.
  1. +10 −0 fireplace/dsl/lazynum.py
@@ -1,4 +1,5 @@
import operator
import random
from .evaluator import Evaluator
@@ -58,3 +59,12 @@ def evaluate(self, source):
return sum(getattr(e, self.tag) for e in entities)
else:
return sum(e.tags[self.tag] for e in entities)
class RandomNumber(LazyNum):
def __init__(self, *args):
super().__init__()
self.choices = args
def evaluate(self, source):
return random.choice(self.choices)

0 comments on commit 5c183f8

Please sign in to comment.