Class: Wiki2Go::WhiteList
- Inherits:
-
Object
- Object
- Wiki2Go::WhiteList
- Defined in:
- lib/Wiki2Go/WhiteList.rb
Instance Method Summary collapse
- #add(item) ⇒ Object
- #all ⇒ Object
- #contains(url) ⇒ Object
-
#initialize(items) ⇒ WhiteList
constructor
A new instance of WhiteList.
- #length ⇒ Object
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 |
#all ⇒ Object
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 |
#length ⇒ Object
19 20 21 |
# File 'lib/Wiki2Go/WhiteList.rb', line 19 def length return @allowed.length end |