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
[].freeze
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(state = nil) ⇒ 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!
9 10 11 |
# File 'lib/github-pages-health-check/checkable.rb', line 9 def check! raise "Not implemented" end |
#reason ⇒ Object
Returns the reason the check failed, if any
23 24 25 26 27 28 |
# File 'lib/github-pages-health-check/checkable.rb', line 23 def reason check! nil rescue GitHubPages::HealthCheck::Error => e e end |
#to_hash ⇒ Object Also known as: [], to_h
30 31 32 33 34 35 36 37 38 |
# File 'lib/github-pages-health-check/checkable.rb', line 30 def to_hash @to_hash ||= begin hash = {} self.class::HASH_METHODS.each do |method| hash[method] = public_send(method) end hash end end |
#to_json(state = nil) ⇒ Object
42 43 44 45 |
# File 'lib/github-pages-health-check/checkable.rb', line 42 def to_json(state = nil) require "json" to_hash.to_json(state) end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/github-pages-health-check/checkable.rb', line 47 def to_s printer.simple_string end |
#to_s_pretty ⇒ Object Also known as: pretty_print
51 52 53 |
# File 'lib/github-pages-health-check/checkable.rb', line 51 def to_s_pretty printer.pretty_print end |
#valid? ⇒ Boolean
Runs all checks, returns true if valid, otherwise false
15 16 17 18 19 20 |
# File 'lib/github-pages-health-check/checkable.rb', line 15 def valid? check! true rescue GitHubPages::HealthCheck::Error false end |