| Total Complexity | 8 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | |||
| 2 | class HTMLElement(object): |
||
| 3 | def __init__(self, place, type, **kwargs): |
||
| 4 | self.type = type |
||
| 5 | self.place = place |
||
| 6 | self.kwargs = kwargs |
||
| 7 | |||
| 8 | @property |
||
| 9 | def as_base(self): |
||
| 10 | return dict( |
||
| 11 | type=None, |
||
| 12 | place=self.place |
||
| 13 | ) |
||
| 14 | |||
| 15 | @property |
||
| 16 | def as_link(self): |
||
| 17 | dct = self.as_base |
||
| 18 | dct.update( |
||
| 19 | type='link', |
||
| 20 | css=self.kwargs.get('css'), |
||
| 21 | text=self.kwargs.get('text'), |
||
| 22 | endpoint=self.kwargs.get('endpoint') |
||
| 23 | ) |
||
| 24 | return dct |
||
| 25 | |||
| 26 | @property |
||
| 27 | def as_button(self): |
||
| 28 | dct = self.as_link |
||
| 29 | css = dct.get('css') |
||
| 30 | dct.update( |
||
| 31 | type='button', |
||
| 32 | css='button{}{}'.format(' ' if css else '', css) |
||
| 33 | ) |
||
| 34 | return dct |
||
| 35 | |||
| 36 | @property |
||
| 37 | def as_stylesheet(self): |
||
| 38 | dct = self.as_base |
||
| 39 | dct.update( |
||
| 40 | type='stylesheet', |
||
| 41 | href=self.kwargs.get('href') |
||
| 42 | ) |
||
| 43 | return dct |
||
| 44 | |||
| 45 | @property |
||
| 46 | def as_javascript(self): |
||
| 47 | dct = self.as_base |
||
| 48 | dct.update( |
||
| 49 | type='javascript', |
||
| 50 | src=self.kwargs.get('src') |
||
| 51 | ) |
||
| 52 | return dct |
||
| 53 | |||
| 54 | @property |
||
| 55 | def as_type(self): |
||
| 56 | return getattr(self, 'as_{}'.format(self.type), self.as_base) |
||
| 57 |