Class: Middleman::Robots::Group
- Inherits:
-
Object
- Object
- Middleman::Robots::Group
- Defined in:
- lib/middleman-robots/group.rb
Overview
Robots Group Class
Group class generate block in robots.txt
Instance Attribute Summary collapse
-
#allow ⇒ Object
readonly
Returns the value of attribute allow.
-
#disallow ⇒ Object
readonly
Returns the value of attribute disallow.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize(rule) ⇒ Group
constructor
A new instance of Group.
- #text ⇒ Object
Constructor Details
#initialize(rule) ⇒ Group
Returns a new instance of Group.
9 10 11 12 13 |
# File 'lib/middleman-robots/group.rb', line 9 def initialize(rule) @user_agent = generate_user_agent(rule) @disallow = generate_disallow(rule) @allow = generate_allow(rule) end |
Instance Attribute Details
#allow ⇒ Object (readonly)
Returns the value of attribute allow.
7 8 9 |
# File 'lib/middleman-robots/group.rb', line 7 def allow @allow end |
#disallow ⇒ Object (readonly)
Returns the value of attribute disallow.
7 8 9 |
# File 'lib/middleman-robots/group.rb', line 7 def disallow @disallow end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
7 8 9 |
# File 'lib/middleman-robots/group.rb', line 7 def user_agent @user_agent end |
Instance Method Details
#text ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/middleman-robots/group.rb', line 15 def text group = [] group << "User-Agent: #{@user_agent}" unless @user_agent.empty? group << @disallow.collect { |item| "Disallow: #{item}" }.join("\n") if @disallow.length.positive? group << @allow.collect { |item| "Allow: #{item}" }.join("\n") if @allow.length.positive? group.join("\n") + "\n" end |