<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kikiki-kiki</author_name>
  <author_url>https://blog.hatena.ne.jp/kikiki-kiki/</author_url>
  <blog_title>かもメモ</blog_title>
  <blog_url>https://chaika.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>モックアップを作っていて、条件によって表示/非表示が分かれる要素があり、ランダムで表示/非表示させたいと思いました。 ランダムに 0 / 1 を返す ぱっと思いついたのが他のJavaScriptとかでもよくやる 0 || 1 を返す方法。 Random.rand(0 .. 1) Random#rand に Range を渡すと Range 内の値がランダムに返されます。 ただ、Rubyの場合 nil と false 以外は true なので 0 も true として扱われてしまいます。したがって if文で条件分岐させるには次のように書かなけれなりませんでした。 if Random.rand(0…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fchaika.hatenablog.com%2Fentry%2F2019%2F07%2F05%2F130000&quot; title=&quot;Ruby ランダムに true / false を返したい - かもメモ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://images-fe.ssl-images-amazon.com/images/I/51uvDkOPVFL._SL160_.jpg</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2019-07-05 13:00:00</published>
  <title>Ruby ランダムに true / false を返したい</title>
  <type>rich</type>
  <url>https://chaika.hatenablog.com/entry/2019/07/05/130000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
