把ios的可读性发挥到极致 —— rubymotion- sugarcube

访问量: 1197

refer to: https://github.com/rubymotion/sugarcube

ruby 这个语言就是把可读性发挥到了极致。 

而 有追求的程序员都是追求极致的,所以又有了  active-support. 

在 rubymotion中,大家延续了这样的风格:  sugarcube. 

# 原始代码:
UIApplication.sharedApplication.openURL(NSURL.URLWithString(url))
# with sugarcube: 
url.nsurl.open

借用一段 官方文档的例子:

require 'sugarcube-animations'

# Careful, once you start using these helpers, you'll never go back.
# 是不是想起了 jquery v.s. raw js,  coffeescript v.s. raw js,  rails v.s. struts ? 

view.move_to [100.0, 100.0] # origin
view.center_to [100.0, 100.0] # center
view.scale_to 2  # double the size, and preserves existing rotation transform
# view.scale_to 4 -> CGAffineTransformMakeScale(4, 4)
# view.scale_to [4, 3] -> CGAffineTransformMakeScale(4, 3)
view.fade_out
view.slide :left, 100

订阅/RSS Feed

Subscribe

分类/category