SymbolBlock.cs 1.16 KB
Newer Older
Eric Domke's avatar
Eric Domke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

namespace ExCSS.Model.TextBlocks
{
    internal class SymbolBlock : Block
    {
        SymbolBlock(GrammarSegment type)
        {
            GrammarSegment = type;
        }

        internal static SymbolBlock Function(string name)
        {
            return new SymbolBlock(GrammarSegment.Function) { Value = name };
        }

        internal static SymbolBlock Ident(string identifier)
        {
            return new SymbolBlock(GrammarSegment.Ident) { Value = identifier };
        }

        internal static SymbolBlock At(string name)
        {
            return new SymbolBlock(GrammarSegment.AtRule) { Value = name };
        }

        internal static SymbolBlock Hash(string characters)
        {
            return new SymbolBlock(GrammarSegment.Hash) { Value = characters };
        }

        internal string Value { get; private set; }

        public override string ToString()
        {
            switch (GrammarSegment)
            {
                case GrammarSegment.Hash:
                    return "#" + Value;

                case GrammarSegment.AtRule:
                    return "@" + Value;
            }

            return Value;
        }
    }
}