Sha256: ad8c1543e6ec6f44c51c517e906981f0ff22a8dd7ef26c25de759a5ce7156f46

Contents?: true

Size: 425 Bytes

Versions: 3

Compression:

Stored size: 425 Bytes

Contents

# frozen_string_literal: true

require "yaml"

module RogueOne
  class DomainList
    attr_reader :path

    def initialize(path)
      @path = path.to_s
    end

    def valid?
      exists? && valid_format?
    end

    def domains
      @domains ||= exists? ? YAML.safe_load(File.read(path)) : nil
    end

    def exists?
      File.exist?(path)
    end

    def valid_format?
      domains.is_a? Array
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rogue_one-0.4.3 lib/rogue_one/domain_list.rb
rogue_one-0.4.2 lib/rogue_one/domain_list.rb
rogue_one-0.4.1 lib/rogue_one/domain_list.rb