class Realize::Logical::Switch::Case
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.
Attributes
transformers[R]
values[R]
Public Class Methods
new(values: [], transformers: [])
click to toggle source
# File lib/realize/logical/switch/case.rb, line 22 def initialize(values: [], transformers: []) @values = array(values).map(&:to_s).to_set @transformers = Transformers.array(transformers) end
Public Instance Methods
match?(value)
click to toggle source
# File lib/realize/logical/switch/case.rb, line 27 def match?(value) values.include?(value.to_s) end