Skip to content

Instantly share code, notes, and snippets.

@kimh
Last active Aug 29, 2015
Embed
What would you like to do?
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