Class: Flag::Feature

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Feature

Returns a new instance of Feature.



67
68
69
70
# File 'lib/flag.rb', line 67

def initialize(name)
  @name = name
  @members = Members.new(name)
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



64
65
66
# File 'lib/flag.rb', line 64

def active
  @active
end

#nameObject (readonly)

Returns the value of attribute name.



65
66
67
# File 'lib/flag.rb', line 65

def name
  @name
end

Instance Method Details

#activatedObject



74
# File 'lib/flag.rb', line 74

def activated; @members.activated end

#keyObject



73
# File 'lib/flag.rb', line 73

def key;       @members.key       end

#off!Object



90
91
92
# File 'lib/flag.rb', line 90

def off!
  @members << "0%"
end

#off?Boolean

Returns:

  • (Boolean)


76
# File 'lib/flag.rb', line 76

def off?; !active? end

#on!(what = "100%") ⇒ Object



94
95
96
# File 'lib/flag.rb', line 94

def on!(what = "100%")
  @members << what
end

#on?(what = false) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
81
82
83
84
85
86
87
88
# File 'lib/flag.rb', line 78

def on?(what = false)
  return active? if !what
  return true    if @members.include?(what)

  case what
  when Integer, Fixnum, String
    @members.groups.any? { |g| Flag.group[g].call(what) }
  else
    false
  end
end

#resetObject



72
# File 'lib/flag.rb', line 72

def reset;     @members.reset     end