Skip to content

Instantly share code, notes, and snippets.

@pocke
Created June 14, 2019 03:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocke/62a796b7c43240a38e7fbe319d459f47 to your computer and use it in GitHub Desktop.
Save pocke/62a796b7c43240a38e7fbe319d459f47 to your computer and use it in GitHub Desktop.
require "net/http"
require "json"
class Pipeline < BasicObject
def self.start
new
end
def initialize
@prev = nil
end
def >(right)
if right.respond_to?(:call)
@prev = right.call(@prev)
else
@prev = right
end
self
end
def method_missing(name, *args)
@prev = @prev.__send__(name, *args)
self
end
end
Pipeline.start
|>>"https://api.github.com/repos/ruby/ruby"
|>> URI.:parse
|>> Net::HTTP.:get
|>> JSON.:parse
|> fetch("stargazers_count")
|>> "Ruby has %d stars".:%
|>> self.:puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment