Class: Flag::Feature
- Inherits:
-
Object
- Object
- Flag::Feature
- Defined in:
- lib/flag.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #activated ⇒ Object
-
#initialize(name) ⇒ Feature
constructor
A new instance of Feature.
- #key ⇒ Object
- #off! ⇒ Object
- #off? ⇒ Boolean
- #on!(what = "100%") ⇒ Object
- #on?(what = false) ⇒ Boolean
- #reset ⇒ Object
Constructor Details
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
79 80 81 |
# File 'lib/flag.rb', line 79 def active @active end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
80 81 82 |
# File 'lib/flag.rb', line 80 def name @name end |
Instance Method Details
#activated ⇒ Object
95 96 97 |
# File 'lib/flag.rb', line 95 def activated @members.activated end |
#key ⇒ Object
91 92 93 |
# File 'lib/flag.rb', line 91 def key @members.key end |
#off! ⇒ Object
115 116 117 |
# File 'lib/flag.rb', line 115 def off! @members << "0%" end |
#off? ⇒ Boolean
99 100 101 |
# File 'lib/flag.rb', line 99 def off? !active? end |
#on!(what = "100%") ⇒ Object
119 120 121 |
# File 'lib/flag.rb', line 119 def on!(what = "100%") @members << what end |
#on?(what = false) ⇒ Boolean
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/flag.rb', line 103 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 |
#reset ⇒ Object
87 88 89 |
# File 'lib/flag.rb', line 87 def reset @members.reset end |