Class: SiteHealth::UrlMap

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/site_health/url_map.rb

Overview

Hash-like data structure that holds URI as keys and can be accessed using an URI instance or the String representation

Instance Method Summary collapse

Constructor Details

#initializeUrlMap



9
10
11
12
13
14
15
# File 'lib/site_health/url_map.rb', line 9

def initialize
  @data = if block_given?
            Hash.new { |hash, key| hash[key] = yield }
          else
            {}
          end
end

Instance Method Details

#[](key) ⇒ Object



26
27
28
# File 'lib/site_health/url_map.rb', line 26

def [](key)
  @data[key.to_s]
end

#[]=(key, value) ⇒ Object

Sets value for key



32
33
34
# File 'lib/site_health/url_map.rb', line 32

def []=(key, value)
  @data[key.to_s] = value
end

#each {|value| ... } ⇒ Enumerator

Returns data.

Yield Parameters:

  • value (Object)

    for key



19
20
21
22
23
# File 'lib/site_health/url_map.rb', line 19

def each
  @data.each do |key, value|
    yield(key, value) if block_given?
  end
end

#to_hHash



37
38
39
# File 'lib/site_health/url_map.rb', line 37

def to_h
  @data
end