以下の通り、vimeo_video
には以下の生のJSON
が入ってます。
pry(#<MoviesController>)> vimeo_video => #<VimeoMe2::Video:0x00007ffe0d1258 @api_version="3.4", @base_uri="https://api.vimeo.com/videos/59", @client= #<VimeoMe2::Http::HttpRequest:0x00007ffe0d1257 @allowed_status=200, @body=nil, @end_point="https://api.vimeo.com/videos/595/comments", @headers={"authorization"=>"Bearer hoge", "Accept"=>"application/vnd.vimeo.*+json;version=3.4", "User-Agent"=>"Vimeo_Me2"}, @last_request= "{\"total\":0,\"page\":1,\"per_page\":25,\"paging\":{\"next\":null,\"previous\":null,\"first\":\"/videos/59/comments?page=1\",\"last\":\"/videos/59/comments?page=1\"},\"data\":[]}", @method="get", @query={}, @ratelimit={"limit"=>"500", "remaining"=>"498", "reset"=>"2021-09-08T13:22:48+00:00"}, @token="hoge">, @token="hoge", @video= {"uri"=>"/videos/59520", "name"=>" - 仮タイトル", "description"=>nil, "type"=>"video", "link"=>"https://vimeo.com/5952/hoge", "duration"=>2061, "width"=>640, "language"=>nil, "height"=>360, "embed"=> {"buttons"=>{"like"=>true, "watchlater"=>true, "share"=>true, "embed"=>true, "hd"=>false, "fullscreen"=>true, "scaling"=>true}, "logos"=>{"vimeo"=>true, "custom"=>{"active"=>false, "url"=>nil, "link"=>nil, "sticky"=>false}}, "title"=>{"name"=>"user", "owner"=>"user", "portrait"=>"user"}, "end_screen"=>[], "playbar"=>true, "volume"=>true, "speed"=>true, "color"=>"00adef", "event_schedule"=>true, "uri"=>nil, "html"=> ... 省略 ... "download"=> [{"quality"=>"source", "type"=>"source", "width"=>854, "height"=>480, "expires"=>"2021-09-09T01:01:56+00:00", "link"=> "https://player.vimeo.com/play/2802205?s=595200946_1631149316_5fb7b1d2b2bb752d1a62d29b4b784604&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CVideoController.&download=1&filename=y2matecom%2B-%2BF%25A1BARWHAT%2BIS%2BYOUR%2BPROFIT%2BSTRUCTURE_480psource.m4v", "created_time"=>"2021-08-31T10:22:55+00:00", "fps"=>23.98, "size"=>157430048, "md5"=>"82ef5759cc1e0569a186c81f06066054", "public_name"=>"Original", "size_short"=>"150.14MB"}, {"quality"=>"sd", "type"=>"video/mp4", "width"=>640, "height"=>360, "expires"=>"2021-09-09T01:01:56+00:00", "link"=> "https://player.vimeo.com/play/28022064?s=595200946_1631149316_731f55e4b38dc9a7f711120d03be0dd7&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CVideoController.&download=1&filename=y2matecom%%2BIS%2BYOUR%2BPROFIT%2BSTRUCTURE_480p164.mp4", #↑のURLのみ抜き出したいです
ちょうど上記のlink
のデータを抜き出し、render status: 200, json: vimeo_video
でView側にjsonを渡したいのですが、いい方法はないでしょうか。
正規表現で抜き出そうかと思いましたが、TypeError: no implicit conversion of VimeoMe2::Video into String
というエラーがでてきて、データ部分を.to_s
しても解決に至りませんでした。
どなたか知恵を貸していただけると幸いです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。