Class: AutoServiceCLI::ServiceCenter
- Inherits:
-
Object
- Object
- AutoServiceCLI::ServiceCenter
- Defined in:
- lib/auto_service_cli/service_center.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#brands ⇒ Object
Returns the value of attribute brands.
-
#description ⇒ Object
Returns the value of attribute description.
-
#ext_url ⇒ Object
Returns the value of attribute ext_url.
-
#int_url ⇒ Object
Returns the value of attribute int_url.
-
#main_category ⇒ Object
Returns the value of attribute main_category.
-
#name ⇒ Object
Returns the value of attribute name.
-
#open_status ⇒ Object
Returns the value of attribute open_status.
-
#payment ⇒ Object
Returns the value of attribute payment.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#services ⇒ Object
Returns the value of attribute services.
-
#slogan ⇒ Object
Returns the value of attribute slogan.
-
#working_hours ⇒ Object
Returns the value of attribute working_hours.
Class Method Summary collapse
- .all ⇒ Object
- .create(name) ⇒ Object
-
.reset_all! ⇒ Object
Class mehods.
Instance Method Summary collapse
- #details_from_hash(details) ⇒ Object
-
#format_rating(rating) ⇒ Object
ex [“two”, “half”] or [“two”].
-
#initialize(name) ⇒ ServiceCenter
constructor
Constructors.
-
#save ⇒ Object
Instance methods.
Constructor Details
#initialize(name) ⇒ ServiceCenter
Constructors
20 21 22 |
# File 'lib/auto_service_cli/service_center.rb', line 20 def initialize(name) @name = name end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def address @address end |
#brands ⇒ Object
Returns the value of attribute brands.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def brands @brands end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def description @description end |
#ext_url ⇒ Object
Returns the value of attribute ext_url.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def ext_url @ext_url end |
#int_url ⇒ Object
Returns the value of attribute int_url.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def int_url @int_url end |
#main_category ⇒ Object
Returns the value of attribute main_category.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def main_category @main_category end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def name @name end |
#open_status ⇒ Object
Returns the value of attribute open_status.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def open_status @open_status end |
#payment ⇒ Object
Returns the value of attribute payment.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def payment @payment end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def phone_number @phone_number end |
#rating ⇒ Object
Returns the value of attribute rating.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def @rating end |
#services ⇒ Object
Returns the value of attribute services.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def services @services end |
#slogan ⇒ Object
Returns the value of attribute slogan.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def slogan @slogan end |
#working_hours ⇒ Object
Returns the value of attribute working_hours.
2 3 4 |
# File 'lib/auto_service_cli/service_center.rb', line 2 def working_hours @working_hours end |
Class Method Details
.all ⇒ Object
74 75 76 |
# File 'lib/auto_service_cli/service_center.rb', line 74 def self.all @@all.dup.freeze end |
.create(name) ⇒ Object
24 25 26 |
# File 'lib/auto_service_cli/service_center.rb', line 24 def self.create(name) self.new(name).tap { |center| center.save } end |
.reset_all! ⇒ Object
Class mehods
70 71 72 |
# File 'lib/auto_service_cli/service_center.rb', line 70 def self.reset_all! @@all.clear end |
Instance Method Details
#details_from_hash(details) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/auto_service_cli/service_center.rb', line 34 def details_from_hash(details) # modify hash's rating if details.include?(:rating) details[:rating] = (details[:rating]) end details.each do |detail, value| self.send("#{detail}=", value) end end |
#format_rating(rating) ⇒ Object
ex [“two”, “half”] or [“two”]
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/auto_service_cli/service_center.rb', line 46 def () case [0] when "one" = "1" when "two" = "2" when "three" = "3" when "four" = "4" when "five" = "5" else # assume it's already formatted return end # TODO << ".5" if .size == 2 && .last == "half" + " star(s)" end |
#save ⇒ Object
Instance methods.
30 31 32 |
# File 'lib/auto_service_cli/service_center.rb', line 30 def save @@all << self end |