Object
Returns an array of lower-cased tokens. If no tag is found, returns an empty array. An optional custom_name specifies the name of a meta tag to look for ahead of “ROBOTS”. Names are compared in a case-insensitive manner.
# File lib/webrobots/nokogiri.rb, line 8 8: def meta_robots(custom_name = nil) 9: (@meta_robots ||= {})[custom_name] = 10: (custom_name && parse_meta_robots(custom_name)) || parse_meta_robots('robots') 11: end
Equivalent to meta_robots(custom_name).include?(‘nofollow’).
# File lib/webrobots/nokogiri.rb, line 19 19: def nofollow?(custom_name = nil) 20: meta_robots(custom_name).include?('nofollow') 21: end
Equivalent to meta_robots(custom_name).include?(‘noindex’).
# File lib/webrobots/nokogiri.rb, line 14 14: def noindex?(custom_name = nil) 15: meta_robots(custom_name).include?('noindex') 16: end
# File lib/webrobots/nokogiri.rb, line 25 25: def parse_meta_robots(custom_name) 26: pattern = /\A#{Regexp.quote(custom_name)}\z/ 27: meta = css('meta[@name]').find { |element| 28: element['name'].match(pattern) 29: } and content = meta['content'] or return [] 30: content.downcase.split(/[,\s]+/) 31: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.