Skip to content

Instantly share code, notes, and snippets.

@manuelkiessling
Created January 28, 2011 16:39
Show Gist options
  • Save manuelkiessling/800520 to your computer and use it in GitHub Desktop.
Save manuelkiessling/800520 to your computer and use it in GitHub Desktop.
Ruby class layout allowing a funny call combination
class Foo
def calculate_for_events(events)
@events = events
self
end
def between(time)
@start_time = time
self
end
def and(time)
@end_time = time
self
end
def in_chunks_of(chunk_size)
@chunk_size = chunk_size
self
end
def minutes
do_something()
end
end
@manuelkiessling
Copy link
Author

Erlaubt Aufrufe wie diesen:

result = Foo.calculate_for_events([e1, e2]).between(Time.now-86400).and(Time.now).in_chunks_of(5).minutes

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