From 62549aae8824dba6a98ca9abd657f50a7f530920 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 13 Dec 2018 14:30:11 -0700 Subject: [PATCH] Functionality to retrieve all sample values --- src/spectator/internals/sample_values.cr | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/spectator/internals/sample_values.cr b/src/spectator/internals/sample_values.cr index 773bb39..8cab714 100644 --- a/src/spectator/internals/sample_values.cr +++ b/src/spectator/internals/sample_values.cr @@ -37,6 +37,13 @@ module Spectator::Internals get_wrapper(id).as(TypedValueWrapper(T)).value end + # Iterates over all values and yields them. + def each + @values.each_value do |entry| + yield entry + end + end + # Represents a single value in the set. private struct Entry # Human-friendly name for the value. @@ -49,5 +56,9 @@ module Spectator::Internals def initialize(@name, @wrapper) end end + + # This must be after `Entry` is defined. + # Could be a Cyrstal compiler bug? + include Enumerable(Entry) end end