MacRuby xcode label not working

class HelloApp attr_accessor :label, :text_field, :button def clickedButton(sender) # implementation your_name = self.text_field.stringValue self.label.stringValue = "Hello, #{your_name}" end end 上面的代码在HelloApp.rb中问题是当我在文本框中输入内容时,点击按钮,标签只是说“你好”,而不是“Hello,namegoeshere”顺便说一句,我使用的是MacRuby。

MacRuby xcode标签不起作用

class HelloApp attr_accessor :label, :text_field, :button def clickedButton(sender) # implementation your_name = self.text_field.stringValue self.label.stringValue = "Hello, #{your_name}" end end 上面的代码在HelloApp.rb中问题是当我在文本框中输入内容时,点击按钮,标签只是说“你好”,而不是“Hello,namegoeshere”顺便说一句,我使用的是MacRuby。

How can I detect whether a file is writeable in Ruby?

The function should return false if any of these are true: The complete path is an existing directory. The path is not a legal file name (invalid characters, too long, etc.) The path refers to an existing file that is not writeable by current user. The path includes any directory segments that do not already exist. The function should return true if all of these are true: All path seg

如何检测文件是否可以在Ruby中写入?

如果其中任何一个为真,函数应该返回false: 完整的路径是一个现有的目录。 该路径不是合法的文件名(无效字符,太长等) 该路径指的是当前用户不可写入的现有文件。 该路径包含任何不存在的目录段。 如果所有这些都是真的,函数应该返回true: 除文件名外的所有路径段都是已经存在的目录。 该文件既不存在也不存在,并且可由当前用户写入。 保存文件的目录可由当前用户写入。 路径段和文件名不会太长,只由文

How to check whether a string contains a substring in Ruby?

I have a string variable with content as follows: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdnn" "/my/name/is/balaji.son" "call::myFunction(int const&)n" "void::secondFunction(char const&)n" . . . "this/is/last/line/liobrary.so" in above string i have to find a sub string ie "hi/ths

如何检查一个字符串是否包含Ruby中的子字符串?

我有一个内容如下的字符串变量: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdnn" "/my/name/is/balaji.son" "call::myFunction(int const&)n" "void::secondFunction(char const&)n" . . . "this/is/last/line/liobrary.so" 在上面的字符串中,我必须找到一个子字符串ie "hi/thsid/sdfhsjdf/dfjsd/sdjfs

Set up S3 bucket as website using ruby SDK

I want to set up an Amazon S3 bucket as a website as described here: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html?r=5271 but using an ruby API, preferably the aws-sdk for ruby. Is there a possibility to do that / a library that already supports that? Could not find anything in aws-sdk and right-aws, but maybe I was just blind? It is possible to configure

使用ruby SDK将S3 bucket设置为网站

我想将这个Amazon S3存储桶设置为一个网站,如下所述: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html?r=5271 但使用红宝石API,最好是红宝石的aws-sdk。 有没有可能做到这一点/一个库已经支持? 在aws-sdk和right-aws中找不到任何东西,但也许我只是瞎了? 可以使用ruby API将您的存储桶配置为网站。 我确实找到了解决方案,但是它使用aws-s3宝石,而不是aws-sdk宝石。 我在pony

Ruby arrays: %w vs %W

有什么不同? %w引用像单引号'' (没有可变内插,更少的转义序列),而%W引号像双引号"" 。 irb(main):001:0> foo="hello" => "hello" irb(main):002:0> %W(foo bar baz #{foo}) => ["foo", "bar", "baz", "hello"] irb(main):003:0> %w(foo bar baz #{foo}) => ["foo", "bar", "baz", "#{foo}"] 我发现的%W和%w的应用程序: greetings = %W(hi hello #{"how do you do"}) # => ["hi"

Ruby数组:%w vs%W

有什么不同? %w引用像单引号'' (没有可变内插,更少的转义序列),而%W引号像双引号"" 。 irb(main):001:0> foo="hello" => "hello" irb(main):002:0> %W(foo bar baz #{foo}) => ["foo", "bar", "baz", "hello"] irb(main):003:0> %w(foo bar baz #{foo}) => ["foo", "bar", "baz", "#{foo}"] 我发现的%W和%w的应用程序: greetings = %W(hi hello #{"how do you do"}) # => ["hi"

Rubocop 25 line block size and RSpec tests

A typical RSpec unit test makes extensive use of nested Ruby blocks in order to structure the code and make use of DSL "magic" to have specs read like BDD statements: describe Foo do context "with a bar" do before :each do subject { Foo.new().add_bar } end it "looks like a baz" do expect # etc In an ideal spec, each example can be relatively short and precis

Rubocop 25行块大小和RSpec测试

一个典型的RSpec单元测试广泛使用嵌套的Ruby块来构建代码并利用DSL“魔术”使规范阅读像BDD语句: describe Foo do context "with a bar" do before :each do subject { Foo.new().add_bar } end it "looks like a baz" do expect # etc 在理想的规格中,每个例子都可以相对简短和精确。 然而,通常有外部块增长到100行以上,因为RSpec结构以这种方式工作,并且不需要很多规范示例,其中每个示例可

ruby

I'm trying to get into BDD with RSpec and I'm having a hard time scaling the techniques past the simple examples. http://betterspecs.org/#contexts informs me that I should use the 'context' method to make my expectations more simple to describe. There are two problems I'm having: 1) Wrapping a test in 'context' creates a new scope, so my setup has to be done multi

红宝石

我试图用RSpec进入BDD,我很难通过简单的例子来扩展这些技术。 http://betterspecs.org/#contexts告诉我,我应该使用'上下文'方法来使我的期望更加简单。 我遇到两个问题: 1)在'上下文'中包装测试创建一个新的范围,所以我的设置必须多次完成。 我还没有找到一种使用'before'钩子来制作这种DRY的方法 - 您可以在下面看到重复的代码。 2)你在下面看到的情况是一步一步的过程,所以每一步都会

How do I run only specific tests in Rspec?

I think there's a way to run only tests with a given label. Anybody know? It isn't easy to find the documentation, but you can tag examples with a hash. Eg. # spec/my_spec.rb describe SomeContext do it "won't run this" do raise "never reached" end it "will run this", :focus => true do 1.should == 1 end end $ rspec --tag focus spec/my_spec.rb More info on GitHub.

我如何在Rspec中只运行特定的测试?

我认为有一种方法可以只运行给定标签的测试。 有人知道吗? 找到文档并不容易,但可以使用散列标记示例。 例如。 # spec/my_spec.rb describe SomeContext do it "won't run this" do raise "never reached" end it "will run this", :focus => true do 1.should == 1 end end $ rspec --tag focus spec/my_spec.rb 更多关于GitHub的信息。 (任何人都有更好的链接,请指教) (更新) RSpec现

Rspec: "array.should == another

I often want to compare arrays and make sure that they contain the same elements, in any order. Is there a concise way to do this in RSpec? Here are methods that aren't acceptable: #to_set For example: array.to_set.should == another_array.to_set This fails when the arrays contain duplicate items. #sort For example: array.sort.should == another_array.sort This fails when the arr

Rspec:“array.should == another

我经常想要比较数组并确保它们以任何顺序包含相同的元素。 在RSpec中有这样简洁的方法吗? 以下是不可接受的方法: #to_set 例如: array.to_set.should == another_array.to_set 当数组包含重复的项目时失败。 #sort 例如: array.sort.should == another_array.sort 当数组元素不执行#<=>时失败 尝试array.should =~ another_array 关于这个我能找到的最好的文档是代码本身,它在这里。 既然RSpec

Testing modules in rspec

What are the best practices on testing modules in rspec? I have some modules that get included in few models and for now I simply have duplicate tests for each model (with few differences). Is there a way to DRY it up? The rad way => let(:dummy_class) { Class.new { include ModuleToBeTested } } Alternatively you can extend the test class with your module: let(:dummy_class) { Class.new {

在rspec中测试模块

在rspec中测试模块的最佳实践是什么? 我有一些模块被包含在少数模型中,现在我只对每个模型进行重复测试(几乎没有区别)。 有没有办法干掉它? rad方式=> let(:dummy_class) { Class.new { include ModuleToBeTested } } 或者,您可以使用模块扩展测试类: let(:dummy_class) { Class.new { extend ModuleToBeTested } } 使用'let'比使用实例变量在before(:each)中定义虚拟类要好, 何时使用RSpec let