Skip to content

Instantly share code, notes, and snippets.

@fcofdez
Last active December 13, 2015 18:28
Show Gist options
  • Save fcofdez/4955358 to your computer and use it in GitHub Desktop.
Save fcofdez/4955358 to your computer and use it in GitHub Desktop.
Code 1
class Computer
def initialize(computer_id, data_source)
@id = computer_id
@data_source = data_source
end
def mouse
info = @data_source.get_mouse_info(@id)
price = @data_source.get_mouse_price(@id)
result = "Mouse: #{info} ($#{price})"
return "* #{result}" if price >= 100
result
end
def cpu
info = @data_source.get_cpu_info(@id)
price = @data_source.get_cpu_price(@id)
result = "Cpu: #{info} ($#{price})"
return "* #{result}" if price >= 100
result
end
def keyboard
info = @data_source.get_keyboard_info(@id)
price = @data_source.get_keyboard_price(@id)
result = "Keyboard: #{info} ($#{price})"
return "* #{result}" if price >= 100
result
end
# ...
end
@fcofdez
Copy link
Author

fcofdez commented Feb 14, 2013

Repetitive code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment