草庐IT

data_send

全部标签

ruby - 使用 ActiveResource 保存时有 'allocator undefined for Data'

我错过了什么?我正在尝试使用Active资源的休息服务,我有以下内容:classUser"Test",:email=>"test.user@domain.com")puserifuser.saveputs"success:#{user.uuid}"elseputs"error:#{user.errors.full_messages.to_sentence}"end以及用户的以下输出:#"Test","email"=>"test.user@domain.com"}>和这个错误:/Library/Ruby/Gems/1.8/gems/activeresource-3.0.10/lib/ac

ruby - 使用 Ruby 和 net-ssh,如何通过 Net::SSH.start 使用 key_data 参数进行身份验证?

我已经阅读了net-ssh文档,但我仍然感到困惑。我可以手动进行身份验证(使用ssh-i...),也可以将key放在文件中并使用:keys参数。但是,我不想使用:keys参数,我想使用:key_data参数。任何人都可以举一个工作的例子吗?出于某种原因,直接将字符串输入:key_data是行不通的,它给出了错误:“既不是PUBkey也不是PRIVkey::嵌套的asn1错误”。当然,我用谷歌搜索了一下,它基本上告诉我要确保key是PEM格式。而且,当然是。有任何想法吗?如果需要,我可以提供更详细的信息... 最佳答案 我看到这个问题

ruby - Aptana 3 ruby​​ 调试器 - DebugThread 循环中的异常 : undefined method `is_binary_data?'

我正在尝试在Aptana3中调试简单的ruby​​文件。classHelloWorlddefinitialize()enddefgreet()puts"helloworld"endendh=HelloWorld.newh.greet断点设置为h.greet在我开始调试后,调试器启动,但是当它尝试初始化ruby​​类时,调试器断开连接并显示消息FastDebugger(ruby-debug-ide0.4.9)listenson:54749ExceptioninDebugThreadloop:undefinedmethod`is_binary_data?'for"#":String当我将断

c - Data_wrap_struct 和标记函数

我正在编写一个Ruby扩展,我正在使用函数Data_wrap_struct。为了参与Ruby的标记和清除垃圾收集过程,我需要定义一个例程来释放我的结构,以及一个例程来标记从我的结构到其他结构的任何引用。我通过经典的free函数来释放内存,但我不知道如何使用标记函数。我的结构听起来像这样typedefstruct{intx;inty;}A;typedefstruct{Acollection[10];intcurrent;}B;我认为我需要一个标记函数来标记结构B的collection中的引用。谁能给我看一个例子,看看标记函数是如何工作的? 最佳答案

ruby - "k.send :hello"- 如果 k 是 "receiver",谁是发件人?

在下面的例子中,为什么我们说“k.send:hello”而不是“k.receive:hello”if,asstatedelsewhere,k实际上是接收者?听起来k是发送者而不是接收者。当我们说“k.send:hello”时,谁在发送,如果不是k?(你是不是和我一样一头雾水?)classKlassdefhello"Hello!"endendk=Klass.newk.send:hello#=>"Hello"k.hello#=>"Hello" 最佳答案 在Smalltalk中,一切都是对象。“发送者”是消息来源范围的所有者对象(即“th

ruby - 为什么 `send` 会因 Ruby 2.0 优化而失败?

为什么这不起作用?moduleStringRefinementrefineStringdodefbarlengthendendendusingStringRefinement"abcdefghijklmnopqrstuvwxyz".send(:bar)#NoMethodError:undefinedmethod'bar'for"abcdefghijklmnopqrstuvwxyz":String有人可以解释为什么send在这里不起作用吗?有没有办法动态调用定义在细化中的方法?我似乎找不到关于Ruby2.0中的改进工作原理的完整解释。 最佳答案

Ruby 相当于 perl 的 "Data::Dumper",用于打印深度嵌套的哈希/数组

这不是RubyequivalentofPerlData::Dumper的副本.这个问题已经超过3.5年了,因此想检查从那时起Ruby中是否有任何可用的新选项。我正在寻找perl的Dumper在ruby​​中的等价物。我不在乎Dumper在幕后做了什么。我已经广泛使用它在perl中打印深度嵌套的哈希和数组。到目前为止,我还没有在ruby​​中找到替代品(或者我可能没有找到一种方法来充分利用Ruby中的可用替代品)。这是我的perl代码及其输出:#!/usr/bin/perl-wusestrict;useData::Dumper;my$hash;$hash->{what}->{where}

ruby-on-rails - Rails 3.1 和 Ruby 1.9.3p125 : ruby-debug19 still crashes with "Symbol not found: _ruby_threadptr_data_type"

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:ruby-debugwithRuby1.9.3?我听说ruby​​1.9.3p125有解决ruby​​-debug19问题的传言,所以根据RVM站点上的说明,我重新安装了1.9.3:$rvmreinstall1.9.3--patchdebug--force-autoconf$ruby-vruby1.9.3p125(2012-02-16revision34643)[x86_64-darwin11.2.0]然后:geminstallruby-debug19将此条目添加到我的Gemfile中:gem'ruby-de

ruby - `sort_by' : comparison of Array with Array failed (no nil data)

classCustomSorterattr_accessor:start_date,:availabledefinitialize(start_date,available)@start_date=Time.mktime(*start_date.split('-'))@available=availableendendcs1=CustomSorter.new('2015-08-01',2)cs2=CustomSorter.new('2015-08-02',1)cs3=CustomSorter.new('2016-01-01',1)cs4=CustomSorter.new('2015-0

ruby - "base.send :include, InstanceMethods"---> 这是做什么的?

我正在查看一个模块X,它包含两个名为“InstanceMethods”和“ClassMethods”的模块。模块X中的最后一个定义是这样的:defself.included(base)base.send:include,InstanceMethodsbase.send:extend,ClassMethodsend这是做什么的? 最佳答案 included在一个模块被包含到另一个模块或类中时被调用。在这种情况下,它将尝试调用base的include方法来从InstanceMethods中获取模块方法、变量和常量添加到base然后将尝试