Class: Enumark

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/enumark.rb,
lib/enumark/dir.rb,
lib/enumark/item.rb,
lib/enumark/config.rb,
lib/enumark/version.rb,
lib/enumark/category.rb,
lib/enumark/grouping.rb

Defined Under Namespace

Modules: Config Classes: Category, Dir, Grouping, Item

Constant Summary collapse

VERSION =
"1.0.0"

Instance Method Summary collapse

Constructor Details

#initialize(file, items: nil) ⇒ Enumark

Returns a new instance of Enumark.



13
14
15
16
17
18
19
20
21
22
# File 'lib/enumark.rb', line 13

def initialize(file, items: nil)
  @file = file
  @lock = Mutex.new
  @items = items

  @hosts = Grouping.new(self, :host)
  @dup_titles = Grouping.new(self, :name){ |groups| groups.select{ |_, items| items.count > 1 } }
  @dup_hrefs = Grouping.new(self, :href){ |groups| groups.select{ |_, items| items.count > 1 } }
  @cates = Grouping.new(self, :categories_str)
end

Instance Method Details

#each(&block) ⇒ Object



24
25
26
27
28
# File 'lib/enumark.rb', line 24

def each(&block)
  read_all_lines
  sort_by_add_date!
  @items.each(&block)
end

#each_category(&block) ⇒ Object



42
43
44
# File 'lib/enumark.rb', line 42

def each_category(&block)
  @cates.each(&block)
end

#each_dup_href(&block) ⇒ Object



38
39
40
# File 'lib/enumark.rb', line 38

def each_dup_href(&block)
  @dup_hrefs.each(&block)
end

#each_dup_title(&block) ⇒ Object



34
35
36
# File 'lib/enumark.rb', line 34

def each_dup_title(&block)
  @dup_titles.each(&block)
end

#each_host(&block) ⇒ Object



30
31
32
# File 'lib/enumark.rb', line 30

def each_host(&block)
  @hosts.each(&block)
end