diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-06 23:12:06 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-06 23:12:06 -0500 |
commit | f0f87c439037715cac407004e2220c678d96757a (patch) | |
tree | 40e9330d709f2b33f6e95fa7b87ec6b3990e3c17 /src/guff/template-token.cr | |
parent | 70e294e312710eb1e89c9cacd09a830e05d4bbe9 (diff) | |
download | old-guff-f0f87c439037715cac407004e2220c678d96757a.tar.bz2 old-guff-f0f87c439037715cac407004e2220c678d96757a.zip |
chaos!
Diffstat (limited to 'src/guff/template-token.cr')
-rw-r--r-- | src/guff/template-token.cr | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/guff/template-token.cr b/src/guff/template-token.cr index 04e8f11..35170d8 100644 --- a/src/guff/template-token.cr +++ b/src/guff/template-token.cr @@ -1,20 +1,24 @@ module Guff class TemplateToken getter :type + getter :value - def initialize(@type : Symbol, @val : String) + TOKEN_TYPES = %i{key val} + + def initialize(@type : Symbol, @value : String) + raise "invalid type: %s" % [@type] unless TOKEN_TYPES.includes?(@type) end def get(args : Hash(String, String)) case @type when :key - raise "missing key: #{@val}" unless args.has_key?(@val) - args[@val] + raise "missing key: %s" % [@value] unless args.has_key?(@value) + args[@value] when :val - @val + @value else # never reached - raise "unknown token type: #{@type}" + raise "unknown token type: %s" % [@type] end end end |