Class: Levels::Audit::Values
- Inherits:
-
Object
- Object
- Levels::Audit::Values
- Includes:
- Enumerable
- Defined in:
- lib/levels/audit/values.rb
Overview
The Values is a set of possible values for a group+value key.
Instance Attribute Summary collapse
-
#group_key ⇒ Object
readonly
Public: Returns a Levels::Key.
-
#value_key ⇒ Object
readonly
Public: Returns a Levels::Key.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Public: Iterate over all potential values.
-
#empty? ⇒ Boolean
Public: Returns true if there are no potential values.
-
#final ⇒ Object
Public: Returns the Levels::Audit::Value marked final.
-
#final_value ⇒ Object
Public: Returns the actual user-defined final value.
-
#initialize(group_key, value_key, values) ⇒ Values
constructor
Initialize a new Values.
- #inspect ⇒ Object
-
#only_final? ⇒ Boolean
Public: Returns true if there is only a final value.
-
#recursive? ⇒ Boolean
Public: Returns true if any of the values are recursive.
-
#size ⇒ Object
Public: Returns the number of potential values.
Constructor Details
#initialize(group_key, value_key, values) ⇒ Values
Initialize a new Values.
group_key - Levels::Key. value_key - Levels::Key. values - Array of Levels::Audit::Value.
12 13 14 15 16 |
# File 'lib/levels/audit/values.rb', line 12 def initialize(group_key, value_key, values) @group_key = group_key @value_key = value_key @values = values end |
Instance Attribute Details
#group_key ⇒ Object (readonly)
Public: Returns a Levels::Key.
19 20 21 |
# File 'lib/levels/audit/values.rb', line 19 def group_key @group_key end |
#value_key ⇒ Object (readonly)
Public: Returns a Levels::Key.
22 23 24 |
# File 'lib/levels/audit/values.rb', line 22 def value_key @value_key end |
Instance Method Details
#each(&block) ⇒ Object
Public: Iterate over all potential values.
37 38 39 |
# File 'lib/levels/audit/values.rb', line 37 def each(&block) @values.each(&block) end |
#empty? ⇒ Boolean
Public: Returns true if there are no potential values.
42 43 44 |
# File 'lib/levels/audit/values.rb', line 42 def empty? @values.empty? end |
#final ⇒ Object
Public: Returns the Levels::Audit::Value marked final.
25 26 27 |
# File 'lib/levels/audit/values.rb', line 25 def final @values.find { |v| v.final? } end |
#final_value ⇒ Object
Public: Returns the actual user-defined final value.
30 31 32 |
# File 'lib/levels/audit/values.rb', line 30 def final_value @values.find { |v| v.final? }.value end |
#inspect ⇒ Object
61 62 63 |
# File 'lib/levels/audit/values.rb', line 61 def inspect "<Values #{group_key.inspect} #{value_key.inspect} #{@values.inspect}>" end |
#only_final? ⇒ Boolean
Public: Returns true if there is only a final value.
47 48 49 |
# File 'lib/levels/audit/values.rb', line 47 def only_final? size == 1 && final end |
#recursive? ⇒ Boolean
Public: Returns true if any of the values are recursive.
52 53 54 |
# File 'lib/levels/audit/values.rb', line 52 def recursive? @values.any? { |v| v.recursive? } end |
#size ⇒ Object
Public: Returns the number of potential values.
57 58 59 |
# File 'lib/levels/audit/values.rb', line 57 def size @values.size end |