Sha256: adc9abbf196378caeda889c10d1b8e423a6719c90746f27dcf9eb89bb7bb65ac

Contents?: true

Size: 415 Bytes

Versions: 1

Compression:

Stored size: 415 Bytes

Contents

require 'uri'

module HatebuWatcher
  class Parameters
    attr_reader :url, :interval

    def initialize(params)
      @url      = params[0]
      @interval = params[1].to_i

      raise ArgumentError unless valid?
    end

    private

    def valid?
      valid_url? && valid_interval?
    end

    def valid_url?
      @url =~ URI::regexp
    end

    def valid_interval?
      @interval > 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hatebu_watcher-0.0.1 lib/hatebu_watcher/parameters.rb