Class: Clownfish::UrlStatuses
- Inherits:
-
Object
- Object
- Clownfish::UrlStatuses
- Defined in:
- lib/clownfish/helpers/url_statuses.rb
Overview
Helper class for pairing urls with status codes.
Instance Attribute Summary collapse
-
#status_codes_by_url ⇒ Object
readonly
Returns the value of attribute status_codes_by_url.
Instance Method Summary collapse
- #add_url(url, status_code) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ UrlStatuses
constructor
A new instance of UrlStatuses.
-
#query(*status_group_specifiers) ⇒ Object
Public: Gets url/status code pairs that match one of the specified status codes.
- #size ⇒ Object
Constructor Details
#initialize ⇒ UrlStatuses
Returns a new instance of UrlStatuses.
6 7 8 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 6 def initialize @status_codes_by_url = {} end |
Instance Attribute Details
#status_codes_by_url ⇒ Object (readonly)
Returns the value of attribute status_codes_by_url.
4 5 6 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 4 def status_codes_by_url @status_codes_by_url end |
Instance Method Details
#add_url(url, status_code) ⇒ Object
10 11 12 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 10 def add_url(url, status_code) @status_codes_by_url[url] = status_code end |
#each(&block) ⇒ Object
14 15 16 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 14 def each(&block) @status_codes_by_url.each(&block) end |
#empty? ⇒ Boolean
22 23 24 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 22 def empty? size == 0 end |
#query(*status_group_specifiers) ⇒ Object
Public: Gets url/status code pairs that match one of the specified status codes.
status_group_specifiers - One, many or an Array of status group specifiers
as accepted by StatusGroup.new.
Returns url/status pairs that match status specifiers.
33 34 35 36 37 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 33 def query(*status_group_specifiers) group = StatusGroup.new(status_group_specifiers) @status_codes_by_url.find_all { |url, code| group.include? code } end |
#size ⇒ Object
18 19 20 |
# File 'lib/clownfish/helpers/url_statuses.rb', line 18 def size @status_codes_by_url.size end |