Class: NameChecker::Availability
- Inherits:
-
Object
- Object
- NameChecker::Availability
- Defined in:
- lib/name_checker/availability.rb
Overview
Container class to represent the availability of a word on a specific service.
Availability.new('twitter', false)
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #available? ⇒ Boolean
-
#initialize(service, status_input) ⇒ Availability
constructor
A new instance of Availability.
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #to_s ⇒ Object
- #unavailable? ⇒ Boolean
- #unknown? ⇒ Boolean
Constructor Details
#initialize(service, status_input) ⇒ Availability
Returns a new instance of Availability.
12 13 14 15 |
# File 'lib/name_checker/availability.rb', line 12 def initialize(service, status_input) @service = service.to_s @status = parse_status(status_input) end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
10 11 12 |
# File 'lib/name_checker/availability.rb', line 10 def service @service end |
#status ⇒ Object
Returns the value of attribute status.
10 11 12 |
# File 'lib/name_checker/availability.rb', line 10 def status @status end |
Instance Method Details
#available? ⇒ Boolean
21 22 23 |
# File 'lib/name_checker/availability.rb', line 21 def available? status == "available" end |
#to_hash ⇒ Object
33 34 35 |
# File 'lib/name_checker/availability.rb', line 33 def to_hash { service: service, status: status } end |
#to_json ⇒ Object
37 38 39 |
# File 'lib/name_checker/availability.rb', line 37 def to_json to_hash.to_json end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/name_checker/availability.rb', line 17 def to_s "#{service}: #{status}" end |
#unavailable? ⇒ Boolean
25 26 27 |
# File 'lib/name_checker/availability.rb', line 25 def unavailable? status == "unavailable" end |
#unknown? ⇒ Boolean
29 30 31 |
# File 'lib/name_checker/availability.rb', line 29 def unknown? status == "unknown" end |