就这么简单:
我怎样才能获得Browser.text.include?
,或红宝石一般,是案件为指定的命令不敏感?
我有这个代码:
File.foreach("testfile.txt") { |line| print line }
lines = File.readlines("testfile.txt")
lines.each { |line| print line }
Run Code Online (Sandbox Code Playgroud)
前任。我如何编辑它以获取特定行testfile.txt
?
$text2 = gets("some code to give me text on line 2 from textfile.txt").chomp
Run Code Online (Sandbox Code Playgroud)
因此,我想运行一个程序来搜索 4 个任何人都可以编辑的不同变量。这些将位于单独的文件中,因此不必重写代码即可更改一组新搜索案例的测试。
假设我有一个文档(我认为文本是最简单的,但可能是错误的),如下所示:
Tea
Coffee
Hot Chocolate
Cookies
Run Code Online (Sandbox Code Playgroud)
这就是文件中的全部内容。另一个文件(.rb)提取这些变量并在谷歌或其他地方搜索它们。如果代码以字节为单位读取,那么我将无法将变量更改为更长或更短的值。
该文件说是可行的
1:Tea
2:Coffee
3:Hot Chocolate
4:Cookies
Run Code Online (Sandbox Code Playgroud)
只要代码只会提取“茶”或“咖啡”,而不是前面的数字。
我很难理解我必须做些什么来提供删除所有"结果"的链接
我正在寻找类似的东西:
<%= button_to 'Remove All', @results, delete_all %>
Run Code Online (Sandbox Code Playgroud)
我正在使用mysql.
编辑 routes.rb:
Productfinder::Application.routes.draw do
resources :contacts
resources :helps
get "help/index"
resources :results
resources :extensions
resources :websites
resources :words
resources :results do
collection do
get 'remove_all'
end
end
get "home/index"
root :to => "results#index"
Run Code Online (Sandbox Code Playgroud) 我想在Watir中重复相同的过程,将(word)作为一个不同的变量,而不在我的.rb文件中再次写出整个代码.所以不必写这个:
website = somewebsite.com
word = someword
browser.goto(website)
if browser.text.include?(word)
puts(website)
end
word = someotherword
browser.goto(website)
if browser.text.include?(word)
puts(website)
end
word = anotherword
browser.goto(website)
if browser.text.include?(word)
puts(website)
end
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
谢谢.
我得到的错误是:
Net::SMTPFatalError: 550 5.7.1 Unable to relay for you@test.lindsaar.net
Run Code Online (Sandbox Code Playgroud)
我在Windows XP上使用带有Ruby 1.9的mail-2.3.0.
我使用的确切代码是:
require 'rubygems'
require 'mail'
Mail.deliver do
from 'me@test.lindsaar.net'
to 'you@test.lindsaar.net'
subject 'Here is the image you wanted'
end
Run Code Online (Sandbox Code Playgroud)
我不明白我错过了什么.谢谢你的帮助.
我在哪里可以找到有关如何限制 rails 在视图中显示的行数的教程?
pagify 选项也很酷……谢谢。