Sha256: ff71fb3b820ecca7f22373898066da7804c715bcc399ef4235d9392242488c84

Contents?: true

Size: 490 Bytes

Versions: 1

Compression:

Stored size: 490 Bytes

Contents

# frozen_string_literal: true

module Conwaymp
  class Options
    include Hanami::Validations

    predicate :file_exists?, message: 'file must exist' do |current|
      File.exist?(File.expand_path(current))
    end

    validations do
      optional(:seed) { str? > included_in?(Conwaymp::Game.available_seeds) }

      required(:rows) { int? & included_in?(1..100) }
      required(:cols) { int? & included_in?(1..100) }

      optional(:load) { str? > file_exists? }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conwaymp-0.2.0 lib/conwaymp/options.rb