Skip to content

Instantly share code, notes, and snippets.

@kimh
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimh/8899670 to your computer and use it in GitHub Desktop.
Save kimh/8899670 to your computer and use it in GitHub Desktop.
Blog Post Sample Code
class Dashing.FizzBuzz extends Dashing.Widget
ready: ->
# ここは初期化時に実行したいエフェクトを書く
onData: (data) ->
$(@node).fadeOut().fadeIn()
<h1 class="title" data-bind="title"></h1>
<div data-bind="value"></div>
class FizzBuzz
FIZZ=3
BUZZ=5
def initialize
@current_num = 1
end
def fizzbuzz
if fizzbuzz?
out = "fizzbuzz"
elsif fizz?
out = "fizz"
elsif buzz?
out = "buzz"
else
out = @current_num
end
go_next
out
end
private
def go_next
@current_num+=1
end
def fizz?
(@current_num % 3) == 0
end
def buzz?
(@current_num % 5) == 0
end
def fizzbuzz?
(@current_num % (FIZZ*BUZZ)) == 0
end
end
fb = FizzBuzz.new
SCHEDULER.every '5s', :first_in => 0 do
send_event('fizz_buzz', { value: fb.fizzbuzz })
end
.widget-fizz-buzz {
background-color: #444;
}
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="fizz_buzz" data-view="FizzBuzz" data-title="Fizz Buzz"></div>
</li>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment