Class: GsImgFetcher::EntrySet

Inherits:
Object
  • Object
show all
Defined in:
lib/gs_img_fetcher/entry_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries) ⇒ EntrySet

Returns a new instance of EntrySet.



19
20
21
# File 'lib/gs_img_fetcher/entry_set.rb', line 19

def initialize(entries)
  @entries = entries
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



17
18
19
# File 'lib/gs_img_fetcher/entry_set.rb', line 17

def entries
  @entries
end

Class Method Details

.from_file(path) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/gs_img_fetcher/entry_set.rb', line 8

def from_file(path)
  entries = File.open(path, 'r') { |f| f.each_line.map(&:strip).map(&:presence) }
                .compact
                .uniq
                .map { |url| Entry.new(url) }
  new(entries)
end

Instance Method Details

#invalid_entriesObject



27
28
29
# File 'lib/gs_img_fetcher/entry_set.rb', line 27

def invalid_entries
  @invalid_entries ||= entries.reject(&:valid?)
end

#valid_entriesObject



23
24
25
# File 'lib/gs_img_fetcher/entry_set.rb', line 23

def valid_entries
  @valid_entries ||= entries.select(&:valid?)
end