Class: Indexmap::IndexNowConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/indexmap/index_now_configuration.rb

Constant Summary collapse

DEFAULT_ENDPOINT =
"https://api.indexnow.org"
DEFAULT_MAX_URLS_PER_REQUEST =
500

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dry_run=(value) ⇒ Object (writeonly)

Sets the attribute dry_run

Parameters:

  • value

    the value to set the attribute dry_run to.



8
9
10
# File 'lib/indexmap/index_now_configuration.rb', line 8

def dry_run=(value)
  @dry_run = value
end

#endpointObject



15
16
17
18
# File 'lib/indexmap/index_now_configuration.rb', line 15

def endpoint
  value = resolve(@endpoint)
  value.to_s.strip.empty? ? DEFAULT_ENDPOINT : value
end

#keyObject



20
21
22
# File 'lib/indexmap/index_now_configuration.rb', line 20

def key
  resolve(@key)
end

#key_filename(key: self.key) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/indexmap/index_now_configuration.rb', line 31

def key_filename(key: self.key)
  configured_filename = resolve(@key_filename)
  return configured_filename unless configured_filename.to_s.strip.empty?
  return if key.to_s.strip.empty?

  "#{key}.txt"
end

#max_urls_per_requestObject



39
40
41
42
43
44
# File 'lib/indexmap/index_now_configuration.rb', line 39

def max_urls_per_request
  value = resolve(@max_urls_per_request)
  return DEFAULT_MAX_URLS_PER_REQUEST if value.nil?

  value.to_i
end

#write_key_file=(value) ⇒ Object (writeonly)

Sets the attribute write_key_file

Parameters:

  • value

    the value to set the attribute write_key_file to.



8
9
10
# File 'lib/indexmap/index_now_configuration.rb', line 8

def write_key_file=(value)
  @write_key_file = value
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/indexmap/index_now_configuration.rb', line 10

def dry_run?
  value = resolve(@dry_run)
  value == true || value.to_s == "1"
end

#write_key_file?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
# File 'lib/indexmap/index_now_configuration.rb', line 24

def write_key_file?
  value = resolve(@write_key_file)
  return !key.to_s.strip.empty? if value.nil?

  value == true || value.to_s == "1"
end