Class: Kudzu::Agent::Robots::RuleSet

Inherits:
Model::Base show all
Defined in:
lib/kudzu/agent/robots/txt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr = {}) ⇒ RuleSet

Returns a new instance of RuleSet.



16
17
18
19
# File 'lib/kudzu/agent/robots/txt.rb', line 16

def initialize(attr = {})
  self.rules = []
  super
end

Instance Attribute Details

#crawl_delayObject

Returns the value of attribute crawl_delay.



14
15
16
# File 'lib/kudzu/agent/robots/txt.rb', line 14

def crawl_delay
  @crawl_delay
end

#rulesObject

Returns the value of attribute rules.



14
15
16
# File 'lib/kudzu/agent/robots/txt.rb', line 14

def rules
  @rules
end

#user_agentObject

Returns the value of attribute user_agent.



14
15
16
# File 'lib/kudzu/agent/robots/txt.rb', line 14

def user_agent
  @user_agent
end

Instance Method Details

#allowed_path?(uri) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/kudzu/agent/robots/txt.rb', line 21

def allowed_path?(uri)
  rules.each do |rule|
    return rule.allow if uri.path =~ rule.path
  end
  return true
end