Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save klustig88/6214909 to your computer and use it in GitHub Desktop.
Save klustig88/6214909 to your computer and use it in GitHub Desktop.
# Solution for Challenge: Design Drill: Public vs. Private Interfaces. Started 2013-08-12T16:17:53+00:00
class BankAccount
attr_reader :customer_name, :type, :acct_number
attr_writer :customer_name
def initialize (customer_name, type, acct_number)
@customer_name = customer_name
@type = type
@acct_number = acct_number.gsub(/\d{3}-\d{3}/, '***-***')
end
def to_s
"My account informaion is: #{customer_name}, #{type}, #{acct_number}"
end
end
my_acct = BankAccount.new("John", "checking", "347-923-239")
p my_acct.customer_name
p my_acct.type
p my_acct.acct_number
p my_acct.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment