Sha256: b2de28913580f9c6b383e70cf73113286485017dfe5825b19471fc83e556ff42

Contents?: true

Size: 931 Bytes

Versions: 2

Compression:

Stored size: 931 Bytes

Contents

module Eco
  module API
    class Session
      class Config
        class Files < Hash

          def initialize(root:)
            super(nil)
            @root        = root
            @validations = {}
          end

          def working_directory=(path)
            self["dir"] = path
          end

          def working_directory
            self["dir"]
          end

          def timestamp_pattern=(pattern)
            self["timestamp_pattern"] = pattern
          end

          def timestamp_pattern
            self["timestamp_pattern"]
          end

          def add_validation(format)
            raise "Block must be given" unless block_given?
            @validations[format] = Proc.new
          end

          def validate(format, input)
            @validations[format].call(input) if  @validations.key?(format)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eco-helpers-0.7.2 lib/eco/api/session/config/files.rb
eco-helpers-0.7.1 lib/eco/api/session/config/files.rb