Class: SiteHealth::UrlMap
- Inherits:
-
Object
- Object
- SiteHealth::UrlMap
- 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
-
#[](key) ⇒ Object
Value for key.
-
#[]=(key, value) ⇒ Object
Sets value for key.
-
#each {|value| ... } ⇒ Enumerator
Data.
-
#initialize ⇒ UrlMap
constructor
A new instance of UrlMap.
-
#to_h ⇒ Hash
Hash representation of data.
Constructor Details
#initialize ⇒ UrlMap
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.
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_h ⇒ Hash
37 38 39 |
# File 'lib/site_health/url_map.rb', line 37 def to_h @data end |