Class: Rx::Helper::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/rx/ruby/Rx.rb

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ Range

Returns a new instance of Range.



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/rx/ruby/Rx.rb', line 96

def initialize(arg)
  @range = { }

  arg.each_pair { |key,value|
    if not ['min', 'max', 'min-ex', 'max-ex'].index(key) then
      raise Rx::Exception.new("illegal argument for Rx::Helper::Range")
    end

    @range[ key ] = value
  }
end

Instance Method Details

#check(value) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/rx/ruby/Rx.rb', line 108

def check(value)
  return false if ! @range['min'   ].nil? and value <  @range['min'   ]
  return false if ! @range['min-ex'].nil? and value <= @range['min-ex']
  return false if ! @range['max-ex'].nil? and value >= @range['max-ex']
  return false if ! @range['max'   ].nil? and value >  @range['max'   ]
  return true
end