require 'rexml/document' def valid_xml?(xml) begin REXML::Document.new(xml) rescue REXML::ParseException # Return nil if a…
concept+introduction 源代码
汇集 concept+introduction 相关的电路原理图、PCB工程文件、单片机/FPGA源代码、数据手册与应用设计方案。
require 'example' e = Example::Class.new e.print_string("Hello World\n") # Hello World #--- # example.rb module Example class Cl…
filename = 'a_file.txt' File.file? filename # => false require 'fileutils' FileUtils.touch(filename) File.…
require 'amazon/search' $AWS_KEY = 'Your AWS key goes here' # See below. def price_books(keyword) req = Amazon::Search::Reques…
hash = { "key1" => "val1", "key2" => "val2" } string = "" hash.each { |k,v| string
$ rails status create create app/controllers create app/helpers create app/models create app/vie…
def run(command, input='') IO.popen(command, 'r+') do |io| io.puts input io.close_write return io.read end end ru…
[1, 2, 3, 4].each { |x| puts x } # 1 # 2 # 3 # 4 #--- [1, 2, 3, 4].collect { |x| x ** 2 } # => [1, 4, 9, 16] #--- ['a'…
#!/usr/bin/env ruby # divide.rb numerator = rand(100) denominator = rand(10) $stderr.puts "Dividing #{numerator} by #{denominator}…
class Frog def initialize(name) @name = name end def speak # It's a well-known fact that only frogs with long n…