株式会社VOYAGE GROUPは、2022年1月、株式会社CARTA HOLDINGSと合併いたしました。 関連リリース:CARTA HOLDINGS、基幹グループ会社のCCIおよびVOYAGE GROUPと統合へ https://cartaholdings.co.jp/news/20210513_01/ CARTA トップへ
Jay Fields' Thoughts: Implementing an internal DSL in Ruby RubyでのDSLの作り方をexpectationsというtesting frameworkを例にとって説明している。 やっぱassert_equalってオブジェクト指向っぽくなくてカッコ悪いよねwここはDSLでカッコよく書きたいものだ。 彼の言いたいことを日本語で超要約してみる。 まず、どういうふうに書きたいかを決める。こんな感じにしたい。 Expectations do # テストだよというブロック expect :expected do # :expectedが期待される値 :expected # ブロックの評価結果が実際の値 end end これから、これをRubyスクリプトとして実行可能な形式にする。 まず、DSLを読み込んだら(実行したら)、Expectatio
タイトルはおおげさすぎ。きっかけは 新しいwhyプロダクト、ShoesはGUIツールキット。 サンプルはこんな感じ。 Shoes.app do button "Press Me" do alert "You pressed me" end end こういうAPIは好みだ。 http://www.rubyist.net/~matz/20070801.html#p02 を見たこと。 「あーinstance_evalはやっぱり便利ですよね」と思ってみてたんだけど*1、この構造って再帰的に使えるよなぁ、と思ったのでコードでメモ。 ポイントは、上のソース中のbuttonというメソッド。buttonメソッドはソースの字面をみると定義なしに突然使われているんだけど、instance_evalの黒魔術を使うとこういうことができる。obj.instance_eval do .. end という構文を使うとブ
Hey! Thousands of people have unlocked their iPhone 4 / 4s in the past year and I want to share with you the most reliable iPhone 4 unlocking services so you too can experience the benefits of this. Unlocking will allow you to use your iPhone 4 / 4s abroad or to get a cheaper deal with a different network at home. In fact, it can be completed with one of the working unlocking services below in a v
Broadly speaking, there are two ways to create a DSL. One is to invent a syntax from scratch, and build an interpreter or compiler. The other is to tailor an existing general-purpose language by adding or changing methods, operators, and default actions. This article explores using the latter method to build a DSL on top of Ruby. A DSL, or domain specific language, is a (usually small) programming
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く