Ruby の Mastodon API ライブラリで new すると下記のようなエラーになります。
irb(main):008:0> client = Mastodon::REST::Client.new(base_url: 'xxxx', bearer_token: 'xxxx')
Traceback (most recent call last):
4: from /Users/xxx/.rbenv/versions/2.6.2/bin/irb:23:in `<main>'
3: from /Users/xxx/.rbenv/versions/2.6.2/bin/irb:23:in `load'
2: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
1: from (irb):8
NameError (uninitialized constant Mastodon::REST)
原因がわからず困ったのですが、似た名前の gem (下記)を事前に誤って install していたのが原因でした。
$ gem info mastodon
*** LOCAL GEMS ***
mastodon (0.3.1)
Author: Colin Shea
Homepage: http://evaryont.me
Installed at: /Users/xxxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0
A Ruby parser for todo.txt files
ちなみに Mastodon API のライブラリはこちら。
$ gem info mastodon-api
*** LOCAL GEMS ***
mastodon-api (2.0.0)
Author: Eugen Rochko
Homepage: https://github.com/tootsuite/mastodon-api
License: MIT
Installed at: /Users/xxxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0
A ruby interface to the Mastodon API
誤って install したほうを uninstall してあげたら解決しました。
$ gem uninstall mastodon
Successfully uninstalled mastodon-0.3.1
Mastodon 自体は 一般的な言葉 ですし、こうしたこともあるのかなと思いました。