mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Structural code for enumerating given value sets
This commit is contained in:
parent
2be9d65997
commit
830aa7b43a
1 changed files with 24 additions and 8 deletions
|
@ -28,19 +28,35 @@ module Spectator
|
||||||
|
|
||||||
macro given(collection, &block)
|
macro given(collection, &block)
|
||||||
context({{collection}}, "Given") do
|
context({{collection}}, "Given") do
|
||||||
def %collection
|
|
||||||
{{collection}}
|
|
||||||
end
|
|
||||||
|
|
||||||
def %first
|
|
||||||
%collection.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def {{block.args.empty? ? "value".id : block.args.first}}
|
def {{block.args.empty? ? "value".id : block.args.first}}
|
||||||
nil # TODO
|
nil # TODO
|
||||||
end
|
end
|
||||||
|
|
||||||
{{block.body}}
|
{{block.body}}
|
||||||
|
|
||||||
|
_given_enumerator Collection%collection, %each do
|
||||||
|
{{collection}}
|
||||||
|
end
|
||||||
|
|
||||||
|
Collection%collection.new.%each do |%item|
|
||||||
|
# TODO
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
macro _given_enumerator(class_name, each_method_name, &block)
|
||||||
|
class {{class_name.id}}
|
||||||
|
include {{@type.id}}
|
||||||
|
|
||||||
|
def %collection
|
||||||
|
{{block.body}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def {{each_method_name.id}}
|
||||||
|
%collection.each do |%item|
|
||||||
|
yield %item
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue