Class: Wiki2Go::WhiteList

Inherits:
Object
  • Object
show all
Defined in:
lib/Wiki2Go/WhiteList.rb

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ WhiteList

Returns a new instance of WhiteList.



6
7
8
# File 'lib/Wiki2Go/WhiteList.rb', line 6

def initialize(items)
  @allowed = items.collect {|line| line.chomp }
end

Instance Method Details

#add(item) ⇒ Object



14
15
16
17
# File 'lib/Wiki2Go/WhiteList.rb', line 14

def add(item)
  @allowed << item
  @allowed = @allowed.sort.uniq
end

#allObject



10
11
12
# File 'lib/Wiki2Go/WhiteList.rb', line 10

def all
  return @allowed
end

#contains(url) ⇒ Object



23
24
25
26
# File 'lib/Wiki2Go/WhiteList.rb', line 23

def contains(url)
  match = @allowed.find { |allowed| url =~ Regexp.new(allowed) }
  ! match.nil?
end

#lengthObject



19
20
21
# File 'lib/Wiki2Go/WhiteList.rb', line 19

def length
  return @allowed.length
end