Class: Enumark

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

Defined Under Namespace

Classes: Category, Dir, Grouping, Item

Constant Summary collapse

VERSION =
"0.1.4"

Instance Method Summary collapse

Constructor Details

#initialize(file, items: nil) ⇒ Enumark

Returns a new instance of Enumark.


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

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


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

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

#each_category(&block) ⇒ Object


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

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

#each_dup_href(&block) ⇒ Object


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

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

#each_dup_title(&block) ⇒ Object


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

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

#each_host(&block) ⇒ Object


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

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