Skip to content

Instantly share code, notes, and snippets.

@mgiagante
Last active May 4, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgiagante/bb06e33bfb54c2da65c78fcc1d6889c8 to your computer and use it in GitHub Desktop.
Save mgiagante/bb06e33bfb54c2da65c78fcc1d6889c8 to your computer and use it in GitHub Desktop.
Encapsulation example for my object-oriented programming series in medium.com
class Dragon
def initialize
# ...
end
def fly
take_off
100.times do
move_wings(:horizontally)
end
land
end
private
def take_off
10.times do
move_wings(:vertically)
end
end
def move_wings(direction)
# ...
end
def land
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment