我需要每月创建一个月份的日志文件.因此,我需要在给定范围内的所有[年,月]元组
你如何迭代日期?
如果我每天需要迭代,怎么办呢?
我正在编写一个基于html画布的简单游戏.我现在正从coffeescript移植到蛋白石.
我想以有效的方式包装CanvasRenderingContext2D对象.
我目前的解决方案是一个包装器,但我真的想让这个免费的桥接器.
app.rb:
class Game
def initialize
@canvas = Element.find('#canvas').get(0)
js_ctx = `this.canvas.getContext('2d')` # this is a javascript object
@ctx = CanvasRenderingContext2D.new(js_ctx) # create the proxy
@ctx.fillStyle='red'
@ctx.fillRect(10,10,50,50)
end
end
# the opal proxy class (named $CanvasRenderingContext2D in javascript space)
class CanvasRenderingContext2D
# I currently model the proxy as a has_a while I'd prefer it to be is_a
attr_reader :js # the native javascript object
def initialize(js)
@js = js
end
# getter
def fillStyle
`this.js.fillStyle`
end
# setter …Run Code Online (Sandbox Code Playgroud)