Module: Party

Defined in:
lib/party.rb

Instance Method Summary collapse

Instance Method Details

#bought(name, item, price) ⇒ Object Also known as: bought2



7
8
9
10
# File 'lib/party.rb', line 7

def bought(name,item, price)
  list[name] << item if item
  money[name] += price
end

#fancy_modeObject

monkey-patches String class to have a buys method



14
15
16
17
18
19
20
21
# File 'lib/party.rb', line 14

def fancy_mode
  # some minor modifications to the String class ;) 
  String.class_eval do
    define_method(:bought) do |*args|
      bought2(self,*args)
    end
  end
end

#participants(*args) ⇒ Object



3
4
5
# File 'lib/party.rb', line 3

def participants(*args)
  @participants ||= args.flatten
end

#summarize(rounding = 2) ⇒ Object



23
24
25
26
27
# File 'lib/party.rb', line 23

def summarize(rounding=2)
  print_bill
  puts
  print_money_due(rounding)
end