`
vivimusing
  • 浏览: 78378 次
  • 性别: Icon_minigender_1
  • 来自: 台州
社区版块
存档分类
最新评论
文章列表
#在application_helper.rb中 def include_ext_js ext_js ="" ext_js << stylesheet_link_tag("/ext/resources/css/ext-all.css") ext_js << javascript_include_tag("/ext/adapter/ext/ext-base.js") ext_js << javascript_include_tag("/ext/ext-all ...
真是受不鸟了,netbeans更新到6.5之后,就卡得一笔。 打开netbeans就得花上个20来秒,之前6.0版本在我机器上面打开只要10来秒的样子! 同一台机器上面打开eclipse只要3秒! ps:Core(TM)2 Duo T7100 @ 1.80Ghz 789MHz,0.97GB
当我们在rails一个工程时,在public文件夹下面有个index.html页面。 我用haml改写一个index.haml 首先我把里面的javascript 和 css 独立的拿出来,放到javascripts/haml.js 和 stylesheets/haml.css中 然后用haml重写这个页面 !!! XML !!! %html %head %meta{'http-equiv' => 'Content-Type', :content => 'text/html',:charset=>"utf-8"} %title Ruby ...
在开发过程中,当项目代码变得越来越复杂之后,html里面的东西就惨不忍睹了。今天google到haml这个东西,稍微体验了下,感觉不错。haml的主页http://haml.hamptoncatlin.com/只要花上几分钟时间就能上手了,还有附加送了sass,简化css代码标记模板,习惯用netbeans的朋友还可以考虑用下点击这里http://mediacast.sun.com/details.jsp?id=3759 这个插件,可以给haml着色。   在ruby文件中我们可以 engine = Haml::Engine.new("%p Haml code!") eng ...
建立一个工程名称为TDD 文件目录结构如下 TDD[test,app,rakefile.rb] test是个存放测试文件的目录 app存放应用的目录 require 'rake/testtask' task :default => [:test] #测试文件命名以"_test"结尾的ruby文档 Rake::TestTask.new('test') do |t| t.pattern= "test/**/*_test.rb" t.warning=true end  
      ActiveSupport 是Rails中的无名英雄。那些大量让Rails代码更加漂亮和强大的功能在ActiveSupport中实现。它加了很多在Rails中普遍使用的方法到核心类中。如果你不介意花时间发觉它们,你会学习到各种方便的技巧,且能应用到你的程序中。 先看下下面这个习惯用法 def create_book book = Book.new book.title = "Trafalgar: The Nelson Touch" book.author = "David Howarth" @db.add(book) boo ...
  def some_method lambda_proc = lambda { return "from lambda"} proc_new_proc = Proc.new { return "from Proc.new"} lambda_proc.call proc_new_proc.call end puts some_method #得到个结果是: #from Proc.new    lambda更像是创建一个佚名的函数。 而Proc.new更像是在代码中多添加那么几行代码。
class A def self.class_method_get_self self end def instances_method_get_self self end end a = A.new puts A.class_method_get_self puts a.instances_method_get_self gets  结果是 A #<A:0x2bd2c78> 其中两个self是指向不同的类,一个指向的是 Class 的一个实例 A ,另外一个指向 A的实例 a
class Module def class_attr_reader(*symbols) symbols.each do |symbol| self.class.send(:define_method,symbol) do class_variable_get( "@@#{symbol}" ) end def class_attr_writter*symbols) symbols.each do |symbol| self.class.send(:define_method,"#{symbol}=") ...
module Lib class<<self def fuc puts "in Lib'fuc" puts self end end end class A include Lib def self.fuc puts "in A'fuc" puts self end end Lib.fuc A.fuc gets   输出结果是 in Lib'fucLibin A'fucA class<<self 相当于批量定义了 def self.someMethods
 对ruby的namespaces一些理解分享下   主要用到的namespaces的关键词是 module , require ,load ,include   module 的作用是圈出一个命名空间理解起来还简单,对于require,load,include的理解,先看下下面的代码     #A.rb module All def self.a print "a\n" end end print "loading in the A.rb\n" #B.rb module All def self.b print "b\n" ...
ClipMainWindow.rb require 'fox16' require 'customer' include Fox class ClipMainWindow < FXMainWindow def initialize(anApp) # Initialize base class first super(anApp, "Clipboard Example", :opts => DECOR_ALL, :width => 400, :height => 300) # Place the list in a su ...
$0 : The name of the top-level Ruby program being executed. __FILE__ : The name of the current source file. $0指当前正在运行的文件,动态的。 __FILE__ 和vc中的一样,指的是当前文件,静态的。
require 'fox16' include Fox app = FXApp.new main = FXMainWindow.new(app, "Hello, World!") button=FXButton.new(main, "Hello, World!") button.tipText = "Push Me!"  以上参见http://vivimusing.iteye.com/admin/blogs/224541 File.open("ruby.jpg", "rb") do ...
require 'fox16' include Fox app = FXApp.new main = FXMainWindow.new(app, "Hello, World!") button=FXButton.new(main, "Hello, World!")  以上参见http://vivimusing.iteye.com/admin/blogs/224254 button.tipText = "Push Me!"  FXButton控件的tipText属性。 button.connect(SEL_COMMAND) ...
Global site tag (gtag.js) - Google Analytics