Install brew if you don't have it.
$ cd ~ && mkdir .telegram-cli && cd .telegram-cli && git clone --recursive https://github.com/vysheng/tg.git && cd tg
Then.
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include"
$ export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib"
$ brew install libconfig readline lua python libevent jansson
export CFLAGS="-I/usr/local/include -I/usr/local/Cellar/readline/7.0.3_1/include"
export LDFLAGS="-L/usr/local/lib -L/usr/local/Cellar/readline/7.0.3_1/lib"
./configure --disable-liblua && make
Be careful of the readline
version. Check your currently installed version and replace the version with yours.
If you have errors see: vysheng/tg#811
Finally
$ gem install telegram-rb