class SPNet::EnumLimiter
Keeps values to those found in the given Enumerable object.
@author James Tunnell
Attributes
values[R]
Public Class Methods
new(values)
click to toggle source
# File lib/spnet/limiters/enum_limiter.rb, line 8 def initialize values raise ArgumentError, "values is not an Enumerable" unless values.is_a?(Enumerable) @values = values end
Public Instance Methods
apply_limit(value, current_value)
click to toggle source
Limit
the given value to those given by @values. If the given value is not found, return the current value.
# File lib/spnet/limiters/enum_limiter.rb, line 15 def apply_limit value, current_value if @values.include? value return value else return current_value end end