Class: Middleman::Robots::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-robots/group.rb

Overview

Robots Group Class

Group class generate block in robots.txt

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#allowObject (readonly)

Returns the value of attribute allow.



7
8
9
# File 'lib/middleman-robots/group.rb', line 7

def allow
  @allow
end

#disallowObject (readonly)

Returns the value of attribute disallow.



7
8
9
# File 'lib/middleman-robots/group.rb', line 7

def disallow
  @disallow
end

#user_agentObject (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

#textObject



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