Advertisement
Guest User

Untitled

a guest
Jun 25th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.37 KB | None | 0 0
  1. def from(str)
  2.   case str.split("/")
  3.   in [name] then "github.com/#{name}/#{name}"
  4.   in [owner, name] then "github.com/#{owner}/#{name}"
  5.   in [host, owner, name] then "#{host}/#{owner}/#{name}"
  6.   end
  7. end
  8.  
  9. puts from("name")
  10. # => github.com/name/name
  11. puts from("owner/name")
  12. # => github.com/owner/name
  13. puts from("github.com/owner/name")
  14. # => github.com/owner/name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement