From 9a7bf3bffb2a8459e66b988aaff53611723b5ab4 Mon Sep 17 00:00:00 2001 From: pepperpepperpepper Date: Sun, 29 Nov 2015 17:43:44 -0800 Subject: required=0, -e commit message for your changes. Lines starting --- ricky/param/options.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ricky/param/options.py (limited to 'ricky/param/options.py') diff --git a/ricky/param/options.py b/ricky/param/options.py new file mode 100644 index 0000000..dadb8f9 --- /dev/null +++ b/ricky/param/options.py @@ -0,0 +1,28 @@ +from ricky.param.option import Option + + +class Options: + def __init__(self, *args): + self._values = args + + def __iter__(self): + return iter(self._values) + + def __len__(self): + return len(self._values) + + def __str__(self): + return str(self._values) + + def __getitem__(self, i): + return self._values[i] + + def search(self, s): + for i in self: + if str(s) in i.value: + return i + + @classmethod + def from_dict(cls, *args): + options = map(lambda x: Option(**x), args) + return cls(*options) -- cgit v1.2.3-70-g09d2