Sha256: 9a1042fe8de89365857d71b0ee0d780e811747551c4c9a3147b6735ceed0f86d
Contents?: true
Size: 693 Bytes
Versions: 11
Compression:
Stored size: 693 Bytes
Contents
# frozen_string_literal: true module Realize class Logical class Switch # This class encapsulates and defines what a switch case statement is. The values # attribute is a list of values to test. The transformers are the transformers to # execute if the value matches. class Case include Arrays acts_as_hashable attr_reader :values, :transformers def initialize(values: [], transformers: []) @values = array(values).map(&:to_s).to_set @transformers = Transformers.array(transformers) end def match?(value) values.include?(value.to_s) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems