ruby元编程之杂记1
Posted
看了Programming Ruby会发现仿佛回到了初高中,一些无聊的英语语法,学了n年!就会讲一句“how are you,Im fine”或者老外问路“I new here too” !就像学一些绕人的武功心法, 但不知奇经八脉在身体哪里,相对现代人而言,白搭。唉!回头看pro ruby还是属于少林派武功,不过咱们还是喜欢武当派的功夫! 还好在学rails的时候认识了Dave才走了捷径,(为什么在学英语的时候没有认Dave一漂呢,不过至少现在认识了小帅)!星期一刚认识了Bill,他说聊到一个有趣绕人的话题,其实也很简单。
话回正题
混乱的模块
module Printable
def print
end
def prepare_cover
end
end
module Document
def print_to_screen
prepare_cover
format_for_screen
print
end
def format_for_screen
end
def print
end
end
class Book
include Document
include Printable
end
b= Book.new
b.print_to_screen
问题:调用哪个print()方法。呵呵。
1.8.7 :036 > Book.ancestors
=> [Book, Printable, Document, Object, Kernel]
想起去年在写rest_api kjava接口的时候的解决方案 android的调用接口如:/android/session.json kjava 的调用接口如:/kjava/session.json 这样命名为了好维护接口,两个接口的格式都不是json.但是考虑到转输流量,数据问题,他们的格式完全不同。在c层逻辑很多相同,有部份逻辑不同。
如果kjava单独再写一部,那么就会知道泰山是怎么垒起来的,也知道为什么泰山那么雄伟,而开发商不去上面开发楼盘的原因了。 好,能用include的方法继承android的方法,让世界变的轻巧多啦。
此文章 短链接: http://dlj.bz/zYwpsx
Tag Cloud
AFNetworking(1)
AngularJS(2)
Devise(1)
Devops(1)
Homebrew(1)
MacOSX(11)
Rails4(2)
TTS(1)
Unauthorized(1)
analysis(1)
android(1)
apache(2)
api(1)
assets(5)
backup(3)
blog(1)
bower(1)
bundle(2)
cache(1)
capistrano(2)
capistrano3(2)
centos(4)
chrome-extension(1)
crontab(1)
css(1)
curl(1)
data(2)
deploy(2)
dlj(1)
dropbox(3)
elasticsearch(1)
fqa(1)
gem(7)
geobean(1)
gfw(1)
gis(1)
git(4)
github(2)
gitlib(1)
google(1)
httpd(1)
iOS(2)
java(1)
javascript(2)
jekyll(1)
js(2)
letsencrypt(1)
linode(2)
linux(16)
memcached(1)
mongodb(5)
mongoid(2)
mongomapper(1)
mtr(1)
mysql(2)
newrelic(1)
nginx(7)
nodejs(1)
notejs(1)
observer(1)
octopress(1)
omniauth-oauth(1)
openlayers(1)
paginate(2)
passenger(2)
pipeline(1)
plugin(2)
production(1)
proxy(3)
rails(23)
rails3(4)
rake(1)
restful_authentication(1)
ruby(28)
rvm(6)
search(1)
siege(1)
sinatra(2)
skill(7)
socks(1)
solr(1)
sql(2)
sqlserver(1)
ssh(6)
ssl(1)
story(4)
sublime-text(3)
sunspot(1)
sweeper(1)
theme(1)
tile(1)
tools(1)
ubuntu(19)
vagrantbox(2)
vps(2)
web(1)
webkit(1)
webpack(1)
win(3)
xcode(2)
yarn(1)
yum(1)
佛(3)
创业(1)
压力测试(2)
正则(1)
转载(7)