class Middleman::Robots::Generators::Block
Generating Block
in robots.txt
Attributes
rule[RW]
Public Class Methods
new(rule)
click to toggle source
# File lib/middleman-robots/generators/block.rb, line 14 def initialize(rule) @rule = rule end
Public Instance Methods
text()
click to toggle source
# File lib/middleman-robots/generators/block.rb, line 18 def text [ user_agent, disallow, allow ].compact.join("\n") end
Private Instance Methods
allow()
click to toggle source
# File lib/middleman-robots/generators/block.rb, line 46 def allow return nil if rule[:allow].nil? raise ArgumentError, '`allow` option must be Array or nil' unless rule[:allow].is_a? Array rule[:allow].map { |path| "Allow: #{File.join('/', path)}" } end
disallow()
click to toggle source
# File lib/middleman-robots/generators/block.rb, line 37 def disallow return nil if rule[:disallow].nil? unless rule[:disallow].is_a? Array raise ArgumentError, '`disallow` option must be Array or nil' end rule[:disallow].map { |path| "Disallow: #{File.join('/', path)}" } end
user_agent()
click to toggle source
# File lib/middleman-robots/generators/block.rb, line 28 def user_agent user_agent = rule[:user_agent].presence || rule['user-agent'].presence || '*' if !user_agent.is_a?(String) && !user_agent.nil? raise ArgumentError, '`user_agent` or `user-agent` option must be String or nil' end "User-Agent: #{user_agent}" end