Upgrade to Pro — share decks privately, control downloads, hide ads and more …

front act of tochigi ruby kaigi 07

front act of tochigi ruby kaigi 07

ドラフト版から変化なし!

seki at druby.org

August 26, 2017
Tweet

More Decks by seki at druby.org

Other Decks in Programming

Transcript

  1. ఻આ্ͷଘࡏ -FBSOGSPNMFHFOEBSZ+BQBOFTF3VCZ IBDLFS .BTBUPTIJ 4FLJ JO UIJT STU &OHMJTI MBOHVBHF

    CPPL PO IJT PXO %JTUSJCVUFE 3VCZ MJCSBSZ :PVMMOEPVUBCPVUEJTUSJCVUFEDPNQVUJOH BEWBODFE 3VCZDPODFQUTBOEUFDIOJRVFT BOEUIFQIJMPTPQIZPG UIF3VCZXBZTUSBJHIUGSPNUIFTPVSDF
  2. History of dRuby 1999-3 ERB 1999-9 DRb 2003 committer 2010

    pokemon-master 2000 Rinda 1998 started ruby 2006 - 2011 Ruby Kaigi MFHFOEBSZ
  3. ঢ়ଶΛऔಘ var load_state = (function(url) { var x; try {

    ... } if (x) { x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { var state = JSON.parse(x.responseText); apply_state(state); } } x.open("GET", url); x.send(null); } }); 9.-)UUQ3FRVFTUך 鷌㾄זⳢ椚 铣׭׋׵⿾僥
  4. ঢ়ଶΛ৔ʹ൓ө var apply_state = (function ( state ) { put_entrance(state,

    last_state); put_hand(state.hand); put_current(state.current, state.prompt); put_outlet(state.outlet, state.prompt); put_costarea(state.costarea); put_candy(state.candy); put_gift(state.gift); put_map(state.map); put_kanban(state.kanban); put_break(state.break); put_red(state.red); put_yellow(state.yellow); put_blue(state.blue); put_prompt(state); last_state = state; }); 朐䡾 㜥䨽חؕ٦س׾ 縧ֻⳢ椚ך⚛ן
  5. handΛ഑ஔ var put_hand = (function (cards) { var x =

    400, z = 1; cards.forEach( function( name ) { card = document.getElementById('mog-' + name); card.src = image_path(name); card.className = "mog-card mog-shadow" card.style.top = 20; card.style.left = x; card.style.zIndex = z; card.draggable = true; { var url = '/api/?tofu_id=api;tofu_cmd=choose;opt=' + (z - 1); card.onclick = function () { load_state(url); }; }; x = x + 125; z = z + 1; }); }); POMJDL ָ٦׿ ֿ׸׮ֲ⢪׏גזְװא 嶊׃䘌׸ 鋅׋湡ך鏣㹀
  6. costareaΛ഑ஔ var put_costarea = (function (cards) { var y =

    -40, z = 1; cards.forEach( function( name ) { card = document.getElementById('mog-' + name); card.src = image_path("ura"); card.className = "mog-card mog-costarea"; card.style.top = y; card.style.left = 100; card.style.zIndex = z; card.draggable = false; card.onclick = null; z = z + 1; y = y + 2; if ( z % 5 === 1 ) { y = y + 2;} }); }); POMJDL OVMM ؕ٦سכ酅ח
  7. API༻ͷWidget class StateTofu < Tofu::Tofu def to_html(context) context.res_header('content-type', 'application/json') body

    = @session.to_hash.to_json context.res_body(body) context.done end def tofu_id 'api' end ٖأهٝأכKTPOדׅ״ せ⵸䝤ְ 8JEHFUך*%
  8. URLͷྫ BQJ UPGV@JEBQJUPGV@DNEDIPPTFPQU var put_hand = (function (cards) { ...

    var url = '/api/?tofu_id=api;tofu_cmd=choose;opt=' + (z - 1); ... 8JEHFUך陎ⴽ㶨 乼⡲ 䒷侧
  9. chooseίϚϯυͷϋϯυϥ def do_choose(context, params) return if @session.finish? deck = @session.deck

    kind, opt = deck.prompt case kind when :spread_else, :outlet_else it ,= params['opt'] num = Integer(it) rescue nil return unless num if (0...(deck.hand.size)) === num card = deck.hand[num] deck.send(kind, card) end end end 䒷侧ךغٔر٦ءّٝ EFDLכְתדֹ׷ֿה׾ 濼׏גְ׷ 朐䡾ך刿倜 EFDLָ؜٦يך朐䡾