Class: Enumark

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

Defined Under Namespace

Classes: Category, Grouping, Hostname, Item

Constant Summary collapse

CATEGORY_START =
/^\s.*<DT><H3/
CATEGORY_END =
/^\s.*<\/DL><p>/
CATEGORY_NAME =
/ADD_DATE="(.*?)".*LAST_MODIFIED="(.*?)".*>(.*)<\/H3/
ITEM_PREFIX =
/^\s.*<DT><A/
ITEM_NAME =
/HREF="(.*?)".*ADD_DATE="(.*?)".*>(.*)<\/A>/
VERSION =
"0.1.3"

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Enumark

Returns a new instance of Enumark.



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/enumark.rb', line 104

def initialize(file)
  @file = file
  @lock = Mutex.new
  @read = false
  @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



116
117
118
119
# File 'lib/enumark.rb', line 116

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

#each_category(&block) ⇒ Object



133
134
135
# File 'lib/enumark.rb', line 133

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

#each_dup_href(&block) ⇒ Object



129
130
131
# File 'lib/enumark.rb', line 129

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

#each_dup_title(&block) ⇒ Object



125
126
127
# File 'lib/enumark.rb', line 125

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

#each_host(&block) ⇒ Object



121
122
123
# File 'lib/enumark.rb', line 121

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