小编bod*_*odo的帖子

Aptana 3 ruby​​调试器 - DebugThread循环中的异常:未定义的方法`is_binary_data?'

我正在尝试在Aptana 3中调试简单的ruby文件.

class HelloWorld

def initialize()

end

def greet()
  puts "hello world"
end
end

h=HelloWorld.new
h.greet
Run Code Online (Sandbox Code Playgroud)

断点设置为

h.greet
Run Code Online (Sandbox Code Playgroud)

在我开始调试之后,调试器启动,但是当它尝试初始化ruby类时,调试器与消息断开连接

Fast Debugger (ruby-debug-ide 0.4.9) listens on :54749
Exception in DebugThread loop: undefined method `is_binary_data?' for "#<HelloWorld:0x85915fc>":String  
Run Code Online (Sandbox Code Playgroud)

当我设置断点时

h=HelloWorld.new
Run Code Online (Sandbox Code Playgroud)

调试器启动,但在我进入initialize()构造函数后,它与先前的消息断开连接

我的宝石列表:

*** LOCAL GEMS ***

archive-tar-minitar (0.5.2)
bigdecimal (1.1.0)
columnize (0.3.6)
io-console (0.3)
json (1.5.4)
linecache19 (0.5.13)
minitest (2.5.1)
rake (0.9.2.2)
rdoc (3.9.4)
ruby-debug-base19 (0.11.26)
ruby-debug-ide19 (0.4.12)
ruby-debug19 (0.11.6)
ruby_core_source (0.1.5)
Run Code Online (Sandbox Code Playgroud)

我已成功应用这些指令,以解决调试问题,但我仍然收到此异常消息

任何答案都是受欢迎的,这可以解决这个问题.

谢谢.

ruby ruby-debug aptana3

6
推荐指数
1
解决办法
3372
查看次数

在监视器监视文件的控制台中没有rspec输出

我已经安装了'guard'和'guard-rspec',我还配置了Guardfile(用于观察'app/views'中的更改)但是当我运行'bundle exec guard'时,我总是得到这个:

  vagrant@vagrant-debian-squeeze:/vagrant/sample_app$ bundle exec guard
  Guard could not detect any of the supported notification libraries.
  Guard is now watching at '/vagrant/sample_app'
  Guard::RSpec is running, with RSpec 2!
  Running all specs
  ........

  Finished in 0.97359 seconds
  8 examples, 0 failures
  >
Run Code Online (Sandbox Code Playgroud)

它已经完成了与后卫控制台提示符下,如果我从编辑"应用程序/视图/"(例如应用程序/视图/ static_pages/home.html.erb)的一些文件并保存,后卫没有表现出任何规格的输出,刚刚还在等待对于一些控制台命令.

我想它应该在保存监视文件后显示一些rspec输出.

的Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.9.0'
  gem 'guard-rspec', '0.5.5'
  gem 'guard'
end

# Gems …
Run Code Online (Sandbox Code Playgroud)

ruby rspec guard ruby-on-rails-3 railstutorial.org

4
推荐指数
1
解决办法
2601
查看次数

为什么String哈希值会发生变化?

我有这个代码:

class DocumentIdentifier
  attr_reader :folder, :name

  def initialize( folder, name )
    @folder = folder
    @name = name
  end

  def ==(other)
    return true if other.equal?(self)
    return false unless other.kind_of?(self.class)
    folder == other.folder && name == other.name
  end

  def hash
    folder.hash ^ name.hash
  end

  def eql?(other)
    return false unless other.instance_of?(self.class)
    other.folder == folder && other.name == name
  end
end

first_id = DocumentIdentifier.new('secret/plans', 'raygun.txt')
puts first_id.hash
Run Code Online (Sandbox Code Playgroud)

为什么每次调用的哈希码都在变化?

我认为它应该与Java中的String哈希代码保持一致.或者,哈希码正在改变,因为每次调用都会给我新的实例foldername?Ruby的String类型具有hash方法的实现,因此相同的String应该为每个调用提供相同的数字.

ruby hashcode

0
推荐指数
1
解决办法
315
查看次数

将参数传递给显式ruby块

您好我正在尝试学习红宝石块.但我很难克服这种结构:

class SomeApp

  attr_accessor :load_listener

  def on_load(&block)
    @load_listener = block
  end

  def load(x)
    @load_listener.call(x) if @load_listener
  end

end

app = SomeApp.new
app.on_load { |x| puts 'on load #{x}'} 
app.load(5)
Run Code Online (Sandbox Code Playgroud)

我不明白为什么这个代码的结果是'on load#{x}',而不是'on load 5' 任何帮助都是值得赞赏的.

ruby parameters block

0
推荐指数
1
解决办法
504
查看次数