Class: Sunnyside::EditService

Inherits:
Object
  • Object
show all
Defined in:
lib/sunnyside/cash_receipts/cash_receipt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(services) ⇒ EditService

Returns a new instance of EditService.



231
232
233
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 231

def initialize(services)
  @services = services.all
end

Instance Attribute Details

#servicesObject (readonly)

Returns the value of attribute services.



229
230
231
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 229

def services
  @services
end

Instance Method Details

#adjustObject



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 239

def adjust
  print "Type in the Service(s) ID # to change the amount: "
  ids     = gets.chomp.split
  ids.each do |id|
    print "You selected #{id} - Type in the adjusted amount: "
    amt    = gets.chomp
    print "And now type in the denial reason: "
    reason = gets.chomp
    adjust_service(id, amt, reason)
  end
end

#adjust_service(id, amt, reason) ⇒ Object



251
252
253
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 251

def adjust_service(id, amt, reason)
  Service[id].update(paid: amt, denial_reason: reason)
end

#show_allObject



235
236
237
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 235

def show_all
  services.each { |svc| puts "ID: #{svc.id} #{svc.dos} #{svc.service_code} #{svc.paid}" }
end