Module: Redis::NotStrict

Included in:
Strict
Defined in:
lib/redis/strict.rb

Overview

This is faster and allows for experimentation with duck-typing.

Instance Method Summary collapse

Instance Method Details

#redis_f(val, msg = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/redis/strict.rb', line 9

def redis_f val, msg = nil
  if Numeric === val
    val
  else
    val_downcase = val.downcase
    if val_downcase == '-inf'
      -1.0/0
    elsif val_downcase =~ /^[+]?inf$/
      1.0/0
    else
      val.to_f
    end
  end
end

#redis_i(val, msg = nil) ⇒ Object



24
25
26
# File 'lib/redis/strict.rb', line 24

def redis_i val, msg = nil
  val.to_i
end

#redis_pos_i(val, msg = 'value is negative') ⇒ Object



28
29
30
31
32
# File 'lib/redis/strict.rb', line 28

def redis_pos_i val, msg = 'value is negative'
  val = redis_i val # may call strict
  raise msg if val < 0
  val
end

#redis_t(*args) ⇒ Object



6
7
# File 'lib/redis/strict.rb', line 6

def redis_t *args
end