Class: MastermindGenerator::Sequence
- Inherits:
-
Object
- Object
- MastermindGenerator::Sequence
- Defined in:
- lib/mastermind_generator/sequence.rb
Overview
Respresents valid sequence that created according to difficulty level
Instance Attribute Summary collapse
-
#difficulty ⇒ Object
readonly
Returns the value of attribute difficulty.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #codes ⇒ Object
-
#initialize(difficulty, value) ⇒ Sequence
constructor
A new instance of Sequence.
Constructor Details
#initialize(difficulty, value) ⇒ Sequence
Returns a new instance of Sequence.
29 30 31 32 33 34 35 36 |
# File 'lib/mastermind_generator/sequence.rb', line 29 def initialize(difficulty, value) @difficulty = difficulty @items = MastermindGenerator .configuration .items[..difficulty.item_count - 1] .map { Item.new(_1) } @value = validate(value) end |
Instance Attribute Details
#difficulty ⇒ Object (readonly)
Returns the value of attribute difficulty.
27 28 29 |
# File 'lib/mastermind_generator/sequence.rb', line 27 def difficulty @difficulty end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
27 28 29 |
# File 'lib/mastermind_generator/sequence.rb', line 27 def items @items end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
27 28 29 |
# File 'lib/mastermind_generator/sequence.rb', line 27 def value @value end |
Instance Method Details
#==(other) ⇒ Object
42 43 44 |
# File 'lib/mastermind_generator/sequence.rb', line 42 def ==(other) value == other.value end |
#codes ⇒ Object
38 39 40 |
# File 'lib/mastermind_generator/sequence.rb', line 38 def codes items.map(&:code) end |