|
|
|
@ -1,20 +1,58 @@ |
|
|
|
|
|
|
|
|
|
class Specs |
|
|
|
|
|
|
|
|
|
macro incompatible_methods(*names) |
|
|
|
|
{% for name in names %} |
|
|
|
|
{% if name.id == "as_s" %} |
|
|
|
|
def {{name}} : String |
|
|
|
|
raise "short string expected; which does not exist in #{self.class}" |
|
|
|
|
end |
|
|
|
|
{% elsif name.id == "as_a_or_s" %} |
|
|
|
|
def {{name}} : Array(String) |
|
|
|
|
raise "list or string expected; which does not exist in #{self.class}" |
|
|
|
|
end |
|
|
|
|
{% elsif name.id == "as_s_or_ls" %} |
|
|
|
|
def {{name}} : String |
|
|
|
|
raise "string or multiline text section expected; which does not exist in #{self.class}" |
|
|
|
|
end |
|
|
|
|
{% end %} |
|
|
|
|
{% end %} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
class StringContainer |
|
|
|
|
property value : String |
|
|
|
|
|
|
|
|
|
def as_s : String |
|
|
|
|
@value |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def as_a_or_s : Array(String) |
|
|
|
|
# FIXME: We should probably be splitting the string around comas. |
|
|
|
|
[@value] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def as_s_or_ls : String |
|
|
|
|
@value |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def initialize(@value) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
class LongStringContainer |
|
|
|
|
Specs.incompatible_methods as_s, as_a_or_s |
|
|
|
|
property value : String |
|
|
|
|
|
|
|
|
|
def as_s_or_ls : String |
|
|
|
|
@value |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def initialize(@value) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
class SectionContainer |
|
|
|
|
Specs.incompatible_methods as_s, as_a_or_s, as_s_or_ls |
|
|
|
|
property value : String |
|
|
|
|
|
|
|
|
|
def initialize(@value) |
|
|
|
@ -22,8 +60,13 @@ class Specs |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
class ArrayContainer |
|
|
|
|
Specs.incompatible_methods as_s, as_s_or_ls |
|
|
|
|
property value : Array(String) |
|
|
|
|
|
|
|
|
|
def as_a_or_s : Array(String) |
|
|
|
|
@value |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def initialize(@value) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|