Class: GitHubPages::HealthCheck::Checkable
- Inherits:
-
Object
- Object
- GitHubPages::HealthCheck::Checkable
- Defined in:
- lib/github-pages-health-check/checkable.rb
Direct Known Subclasses
Constant Summary collapse
- HASH_METHODS =
Array of symbolized methods to be included in the output hash
[]
Instance Method Summary collapse
- #check! ⇒ Object (also: #valid!)
-
#reason ⇒ Object
Returns the reason the check failed, if any.
- #to_hash ⇒ Object (also: #[], #to_h)
- #to_json ⇒ Object
- #to_s ⇒ Object
- #to_s_pretty ⇒ Object (also: #pretty_print)
-
#valid? ⇒ Boolean
Runs all checks, returns true if valid, otherwise false.
Instance Method Details
#check! ⇒ Object Also known as: valid!
8 9 10 |
# File 'lib/github-pages-health-check/checkable.rb', line 8 def check! raise "Not implemented" end |
#reason ⇒ Object
Returns the reason the check failed, if any
22 23 24 25 26 27 |
# File 'lib/github-pages-health-check/checkable.rb', line 22 def reason check! nil rescue GitHubPages::HealthCheck::Error => e e end |
#to_hash ⇒ Object Also known as: [], to_h
29 30 31 32 33 34 35 36 37 |
# File 'lib/github-pages-health-check/checkable.rb', line 29 def to_hash @hash ||= begin hash = {} self.class::HASH_METHODS.each do |method| hash[method] = public_send(method) end hash end end |
#to_json ⇒ Object
41 42 43 44 |
# File 'lib/github-pages-health-check/checkable.rb', line 41 def to_json require 'json' to_hash.to_json end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/github-pages-health-check/checkable.rb', line 46 def to_s printer.simple_string end |
#to_s_pretty ⇒ Object Also known as: pretty_print
50 51 52 |
# File 'lib/github-pages-health-check/checkable.rb', line 50 def to_s_pretty printer.pretty_print end |
#valid? ⇒ Boolean
Runs all checks, returns true if valid, otherwise false
14 15 16 17 18 19 |
# File 'lib/github-pages-health-check/checkable.rb', line 14 def valid? check! true rescue GitHubPages::HealthCheck::Error false end |