Sha256: 2f764cfdc7c8920abb74882073fc98f45df967216d1b75f6842faee687bb783c

Contents?: true

Size: 725 Bytes

Versions: 2

Compression:

Stored size: 725 Bytes

Contents

module RubyQuiz1
  class Message

    def initialize(value, solitaire=Solitaire.new(StandardDeck.new))
      @value = value
      @solitaire = solitaire
    end

    def encrypt
      character_groups.collect(&:encrypted).join(" ")
    end

    def decrypt
      character_groups.collect(&:decrypted).join(" ")
    end

  private

    def value
      @value
    end

    def stripped_value
      value.upcase.gsub(/[^A-Z]/,"")
    end

    def solitaire
      @solitaire
    end

    def character_groups
      @character_groups ||= begin
        stripped_value.chars.each_slice(5).collect do |character_group_value|
          CharacterGroup.new character_group_value.join, solitaire
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_quiz_1-0.0.2 lib/ruby_quiz_1/message.rb
ruby_quiz_1-0.0.1 lib/ruby_quiz_1/message.rb