Completed
Push — dev-4.1-unstable ( 136355...f650fd )
by Felipe A.
01:01
created

HTMLElement   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 55
rs 10
c 1
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A as_javascript() 0 8 1
A as_type() 0 3 1
A as_stylesheet() 0 8 1
A as_link() 0 10 1
A as_base() 0 5 1
A __init__() 0 4 1
A as_button() 0 9 2
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