<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>obelisk2</author_name>
  <author_url>https://blog.hatena.ne.jp/obelisk2/</author_url>
  <blog_title>Camera Obscura</blog_title>
  <blog_url>https://obelisk.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>Ruby はインクリメントやデクリメントがないのですが、遊びでカウンターを作ってみました。メタプログラミングを使って、呼び出されるたびに step（デフォルトは 1）だけ増える数を与えるメソッドを生成します。「メソッド」というのが工夫したところです。使い方は、Counter.make(:inc) でカウンター inc を作成します。カウンターの名前は何でも構いません。デフォルトの初期値は 0、step は 1です。 Counter.make(:inc) 5.times {puts inc} #=&gt;0 1 2 3 4 Counter.make(:count, 100, -5) puts coun…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fobelisk.hatenablog.com%2Fentry%2F2016%2F11%2F10%2F211451&quot; title=&quot;Ruby のメタプログラミングでカウンターを作る - Camera Obscura&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></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2016-11-10 21:14:51</published>
  <title>Ruby のメタプログラミングでカウンターを作る</title>
  <type>rich</type>
  <url>https://obelisk.hatenablog.com/entry/2016/11/10/211451</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
