Class: RogueOne::DomainList
- Inherits:
-
Object
- Object
- RogueOne::DomainList
- Defined in:
- lib/rogue_one/domain_list.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #domains ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(path) ⇒ DomainList
constructor
A new instance of DomainList.
- #valid? ⇒ Boolean
- #valid_format? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ DomainList
Returns a new instance of DomainList.
9 10 11 |
# File 'lib/rogue_one/domain_list.rb', line 9 def initialize(path) @path = path.to_s end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/rogue_one/domain_list.rb', line 7 def path @path end |
Instance Method Details
#domains ⇒ Object
17 18 19 |
# File 'lib/rogue_one/domain_list.rb', line 17 def domains @domains ||= exists? ? YAML.safe_load(File.read(path)) : nil end |
#exists? ⇒ Boolean
21 22 23 |
# File 'lib/rogue_one/domain_list.rb', line 21 def exists? File.exist?(path) end |
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/rogue_one/domain_list.rb', line 13 def valid? exists? && valid_format? end |
#valid_format? ⇒ Boolean
25 26 27 |
# File 'lib/rogue_one/domain_list.rb', line 25 def valid_format? domains.is_a? Array end |