Skip to content

Instantly share code, notes, and snippets.

@Solnse
Created April 28, 2014 23:38
Show Gist options
  • Save Solnse/11387105 to your computer and use it in GitHub Desktop.
Save Solnse/11387105 to your computer and use it in GitHub Desktop.
class Reward::Card
def initialize(params)
@type = params[:type]
@username = params[:username]
@password = params[:password]
@klass = Object.const_get(@type.capitalize)
end
def reward_balance
begin
@klass.card_balance
rescue => e
puts e.message
puts "unknown class: #{@klass}"
end
end
end
class Starbucks < Reward
def self.card_balance
puts "call to starbucks card_balance."
puts @username
puts @password
end
end
class United < Reward
def self.card_balance
puts "call to united card_balance."
puts @type
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment