Skip to content

Instantly share code, notes, and snippets.

@suryart
Created February 25, 2018 14:29
Show Gist options
  • Save suryart/15d27dca601687e2ad0da1ffa8cd89f1 to your computer and use it in GitHub Desktop.
Save suryart/15d27dca601687e2ad0da1ffa8cd89f1 to your computer and use it in GitHub Desktop.
module InstanceModule
def track
"Tracking todo: #{self.name}"
end
end
module ClassModule
def class_name
"Tracking class: #{self.name}"
end
end
class Todo
include InstanceModule
extend ClassModule
attr_reader :name
def initialize(task_name)
@name = task_name
end
end
t = Todo.new('read a blog')
puts t.track
puts Todo.class_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment