Skip to content

Instantly share code, notes, and snippets.

@rvbsanjose
Forked from kunalbhatt/object_privacy.rb
Created October 12, 2012 00:24
Show Gist options
  • Save rvbsanjose/3876606 to your computer and use it in GitHub Desktop.
Save rvbsanjose/3876606 to your computer and use it in GitHub Desktop.
Object Privacy
class BankAccount
def initialize(customer_name, type, acct_number)
@customer_name = customer_name
@type = type
@acct_number = acct_number
end
def customer_name=(customer_name)
@customer_name = customer_name
end
def customer_name
@customer_name
end
def type=(type)
@type = type
end
def type
@type
end
def acct_number
@acct_number.sub(/\d{3}-\d{2}-/, "XXX-XX-#{$3}")
end
def to_s
"#{@customer_name}: #{@type} # #{acct_number}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment