Class: Probot::ParsedLine

Inherits:
Struct
  • Object
show all
Defined in:
lib/probot.rb

Overview

ParedLine Note: In the case of ‘Sitemap: example.com/sitemap.xml’, raw_value needs to rejoin after splitting the URL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#input_stringObject

Returns the value of attribute input_string

Returns:

  • (Object)

    the current value of input_string



127
128
129
# File 'lib/probot.rb', line 127

def input_string
  @input_string
end

Instance Method Details

#agent?Boolean

Returns:

  • (Boolean)


136
# File 'lib/probot.rb', line 136

def agent? = key == "user-agent"

#allow?Boolean

Returns:

  • (Boolean)


140
# File 'lib/probot.rb', line 140

def allow? = key == "allow"

#clean_urlObject



134
# File 'lib/probot.rb', line 134

def clean_url = clean_value&.then { URI(_1).to_s }

#clean_valueObject



132
# File 'lib/probot.rb', line 132

def clean_value = raw_value.split("#").first&.strip

#crawl_delay?Boolean

Returns:

  • (Boolean)


142
# File 'lib/probot.rb', line 142

def crawl_delay? = key == "crawl-delay"

#disallow?Boolean

Returns:

  • (Boolean)


138
# File 'lib/probot.rb', line 138

def disallow? = key == "disallow"

#keyObject



128
# File 'lib/probot.rb', line 128

def key = input_string.split(":").first&.strip&.downcase

#raw_valueObject



130
# File 'lib/probot.rb', line 130

def raw_value = input_string.split(":").slice(1..)&.join(":")&.strip

#sitemap?Boolean

Returns:

  • (Boolean)


144
# File 'lib/probot.rb', line 144

def sitemap? = key == "sitemap"

#valueObject



146
147
148
149
150
151
152
153
154
155
# File 'lib/probot.rb', line 146

def value
  return clean_value.to_f if crawl_delay?
  return clean_url if disallow? || allow?

  raw_value
rescue URI::InvalidURIError
  raw_value
rescue ArgumentError
  raw_value
end