Class: Scrape::RobotsTxtRules
- Inherits:
-
Object
- Object
- Scrape::RobotsTxtRules
- Defined in:
- lib/scrape/robots_txt_rules.rb
Instance Method Summary collapse
- #+(ary) ⇒ Object
- #<<(rule) ⇒ Object
- #=~(str) ⇒ Object
-
#initialize(*rules) ⇒ RobotsTxtRules
constructor
A new instance of RobotsTxtRules.
- #to_a ⇒ Object (also: #to_ary)
Constructor Details
#initialize(*rules) ⇒ RobotsTxtRules
Returns a new instance of RobotsTxtRules.
2 3 4 |
# File 'lib/scrape/robots_txt_rules.rb', line 2 def initialize *rules @rules = rules.flatten end |
Instance Method Details
#+(ary) ⇒ Object
11 12 13 |
# File 'lib/scrape/robots_txt_rules.rb', line 11 def + ary dup << ary.to_ary end |
#<<(rule) ⇒ Object
6 7 8 9 |
# File 'lib/scrape/robots_txt_rules.rb', line 6 def << rule @rules.push *Array(rule).flatten self end |
#=~(str) ⇒ Object
15 16 17 18 |
# File 'lib/scrape/robots_txt_rules.rb', line 15 def =~ str str = str.to_str @rules.any?{|rule| str.starts_with rule } end |
#to_a ⇒ Object Also known as: to_ary
20 21 22 |
# File 'lib/scrape/robots_txt_rules.rb', line 20 def to_a @rules.dup end |