Class: Rcurtain::Curtain

Inherits:
Object
  • Object
show all
Defined in:
lib/rcurtain/curtain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Curtain

Returns a new instance of Curtain.



6
7
8
# File 'lib/rcurtain/curtain.rb', line 6

def initialize (url)
  @redis = Redis.new(:url => url)
end

Instance Attribute Details

#redisObject (readonly)

Returns the value of attribute redis.



4
5
6
# File 'lib/rcurtain/curtain.rb', line 4

def redis
  @redis
end

Instance Method Details

#opened?(feature, users = []) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
# File 'lib/rcurtain/curtain.rb', line 10

def opened? (feature, users = [])
  feat = get_feature(feature)

  return (compare_percentage?(feat.percentage)) || (users.any? { |user| feat.users.include?(user)}) unless users.empty?

  compare_percentage?(feat.percentage)
rescue Redis::CannotConnectError
  return false
end