Sha256: 22b291a4b956763520cf2e97b31062e689652c6057eb558fa59bdc130aa16711

Contents?: true

Size: 529 Bytes

Versions: 2

Compression:

Stored size: 529 Bytes

Contents

module Codebreaker
  class CreateStatService
    def initialize(game)
      @game = game
    end

    def call
      StatsStorage.new.add(stat_data)
    end

    private

    def stat_data
      {
        name: @game.player.name,
        difficulty: @game.difficulty.type,
        attempts_total: @game.difficulty.attempts,
        attempts_used: @game.difficulty.attempts - @game.attempts_left,
        hints_total: @game.difficulty.hints,
        hints_used: @game.difficulty.hints - @game.hints_left
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cb-core-0.1.8 lib/codebreaker/create_stat_service.rb
cb-core-0.1.7 lib/codebreaker/create_stat_service.rb