草庐IT

java - 无法从 R.java 将 int 转换为 String

全部标签

ruby-on-rails - 如何将 'Fixnum' 转换为 Rails 3.1.3 中的日期?

我正在尝试将此输出显示为日期:1296524384但是当我在上面调用.to_date时,出现了这个错误:undefinedmethod`to_date'for1296524384:Fixnum 最佳答案 你可以这样做:the_time=Time.at(1296524384)这给你:2011-01-3120:39:44-0500顺便说一句,1296524384指的是UNIX或纪元时间。它测量自1970年1月1日以来经过的秒数。为了更好地格式化它,您可以使用Ruby的strftime方法。the_time=Time.at(1296524

ruby-on-rails - 如何将此 Ruby 字符串转换为数组?

将以下Ruby字符串转换为数组的最佳方法是什么(我使用的是ruby​​1.9.2/Rails3.0.11)Rails控制台:>Item.first.ingredients=>"[\"Bread,wholewheat,100%,slice\",\"EggSubstitute\",\"new,Eggs,scrambled\"]">Item.first.ingredients.class.name=>"String">Item.first.ingredients.length77期望的输出:>Item.first.ingredients_a["Bread,wholewheat,100%,sl

python - 将行转换为列

我有一个如下所示的行文件,我想将其转换为两列格式。>00000_x1688514TGCTTGGACTACATATGGTTGAGGGTTGTA>00001_x238968TGCTTGGACTACATATTGTTGAGGGTTGTA...期望的输出是>00000_x1688514TGCTTGGACTACATATGGTTGAGGGTTGTA>00001_x238968TGCTTGGACTACATATTGTTGAGGGTTGTA...如果有任何帮助,我将不胜感激。谢谢。 最佳答案 我不知道您是否知道用于读/写和其他遗传功能的BioPerl模

ruby - 如何将字符串格式的毫秒数转换为 HH :MM:SS format in Ruby in under 3 lines of code?

@scores_raw.eachdo|score_raw|#belowiscodeiftimewasbeingsentinmillisecondshh=((score_raw.score.to_i)/100)/3600mm=(hh-hh.to_i)*60ss=(mm-mm.to_i)*60crumbs=[hh,mm,ss]sum=crumbs.first.to_i*3600+crumbs[1].to_i*60+crumbs.last.to_i@scoressum,:hms=>hh.round.to_s+":"+mm.round.to_s+":"+ss.round.to_s}@score

ruby-on-rails - 无法捆绑安装 'open-uri'

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。关于您编写​​的代码问题的问题必须在问题本身中描述具体问题—并且包括有效代码以重现它。参见SSCCE.org寻求指导。关闭8年前。Improvethisquestion我是Rails的新手。我正在制作一个网络应用程序,我在其中使用nokogiri搜索不同的网站以从中提取文本。所以在Gemfile中,我写了require'nokogiri'和'open-uri',但是当我捆绑安装时我得到这个错误:Couldnotfindgem'open-uri(>=0)ruby'inthegemsavailableon

ruby - json 没有将 String 隐式转换为 Integer (TypeError)

玩转ruby​​,我已经:#!/usr/bin/ruby-w#WorldweatheronlineAPIurlformat:http://api.worldweatheronline.com/free/v1/weather.ashx?q={location}&format=json&num_of_days=1&date=today&key={api_key}require'net/http'require'json'@api_key='xxx'@location='city'@url="http://api.worldweatheronline.com/free/v1/weather.

ruby - libxml-ruby 无法在 x86_64 上加载

我们在服务器端遇到libxml-rubygem的问题可能是因为它使用x86_64架构:$uname-aLinuxip-10-228-171-642.6.21.7-2.fc8xen-ec2-v1.0#1SMPTueSep110:25:30EDT2009x86_64GNU/Linuxrequire'libxml'LoadError:/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml_ruby.so:invalidELFheader-/usr/local/ruby-enterprise/

ruby-on-rails - ruby rails 将参数转换为 int 数组

我正在通过get发送数据,我需要将其放入一个int数组中以便在查找中使用。这是我的代码:@found=Array.newparams['candidate'].eachdo|c|@found我的网址是这样的http://localhost:3000/export/candidate?candidate[]=3&candidate[]=4&commit=Export如果它有任何不同,我将它用于此查找@candidate=Candidate.find(:all,:conditions=>["candidates.idIN?",@found])但目前它并没有把它放在一个真正的数组中,因为我得

ruby - 如何将字符串转换为方法调用?

这个问题在这里已经有了答案:Howtocallmethodsdynamicallybasedontheirname?[duplicate](5个答案)关闭8年前。如何使用字符串作为方法调用?"SomeWord".class#=>Stringa="class""SomeWorld".a#=>undefinedmethod'a'"SomeWorld"."#{a}"#=>syntaxerror,unexpectedtSTRING_BEG

ruby - 类型错误 : can't convert String into Integer

我有代码:classScenedefinitialize(number)@number=numberendattr_reader:numberendscenes=[Scene.new("one"),Scene.new("one"),Scene.new("two"),Scene.new("one")]groups=scenes.inject({})do|new_hash,scene|new_hash[scene.number]=[]ifnew_hash[scene.number].nil?new_hash[scene.number]当我启动它时出现错误:freq.rb:11:in`[]'