Class: RubyQuiz1::CharacterGroup
- Inherits:
-
Object
- Object
- RubyQuiz1::CharacterGroup
- Defined in:
- lib/ruby_quiz_1/character_group.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #characters ⇒ Object
- #decrypted ⇒ Object
- #encrypted ⇒ Object
-
#initialize(value, solitaire = nil) ⇒ CharacterGroup
constructor
A new instance of CharacterGroup.
- #numbers ⇒ Object
Constructor Details
#initialize(value, solitaire = nil) ⇒ CharacterGroup
Returns a new instance of CharacterGroup.
4 5 6 7 8 |
# File 'lib/ruby_quiz_1/character_group.rb', line 4 def initialize(value, solitaire=nil) raise ArgumentError unless String(value) =~ /\A[A-Z]{1,5}\z/ @value = String(value) @keystream = generate_keystream(solitaire) if solitaire end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 |
# File 'lib/ruby_quiz_1/character_group.rb', line 30 def ==(other) characters == other.characters end |
#characters ⇒ Object
10 11 12 |
# File 'lib/ruby_quiz_1/character_group.rb', line 10 def characters pad(value) end |
#decrypted ⇒ Object
25 26 27 28 |
# File 'lib/ruby_quiz_1/character_group.rb', line 25 def decrypted return unless keystream convert_to_characters(decrypted_numbers) end |
#encrypted ⇒ Object
20 21 22 23 |
# File 'lib/ruby_quiz_1/character_group.rb', line 20 def encrypted return unless keystream convert_to_characters(encrypted_numbers) end |
#numbers ⇒ Object
14 15 16 17 18 |
# File 'lib/ruby_quiz_1/character_group.rb', line 14 def numbers @numbers ||= characters.chars.collect do |c| ("A".."Z").to_a.index(c) + 1 end end |