class AutoServiceCLI::ServiceCenter
Attributes
address[RW]
brands[RW]
description[RW]
ext_url[RW]
int_url[RW]
main_category[RW]
name[RW]
open_status[RW]
payment[RW]
phone_number[RW]
rating[RW]
services[RW]
slogan[RW]
working_hours[RW]
Public Class Methods
all()
click to toggle source
# File lib/auto_service_cli/service_center.rb, line 74 def self.all @@all.dup.freeze end
create(name)
click to toggle source
# File lib/auto_service_cli/service_center.rb, line 24 def self.create(name) self.new(name).tap { |center| center.save } end
new(name)
click to toggle source
Constructors
# File lib/auto_service_cli/service_center.rb, line 20 def initialize(name) @name = name end
reset_all!()
click to toggle source
Class mehods
# File lib/auto_service_cli/service_center.rb, line 70 def self.reset_all! @@all.clear end
Public Instance Methods
details_from_hash(details)
click to toggle source
# 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] = format_rating(details[:rating]) end details.each do |detail, value| self.send("#{detail}=", value) end end
format_rating(rating)
click to toggle source
ex [“two”, “half”] or [“two”]
# File lib/auto_service_cli/service_center.rb, line 46 def format_rating(rating) case rating[0] when "one" new_rating = "1" when "two" new_rating = "2" when "three" new_rating = "3" when "four" new_rating = "4" when "five" new_rating = "5" else # assume it's already formatted return rating end # TODO new_rating << ".5" if rating.size == 2 && rating.last == "half" new_rating + " star(s)" end
save()
click to toggle source
Instance methods.
# File lib/auto_service_cli/service_center.rb, line 30 def save @@all << self end