Project

General

Profile

Feature #10175 » UseKernel#proc.PATCH

gogotanaka (Kazuki Tanaka), 08/27/2014 07:51 PM

View differences:

lib/cgi/session.rb
attr_reader :session_id, :new_session
def Session::callback(dbman) #:nodoc:
Proc.new{
proc {
dbman[0].close unless dbman.empty?
}
end
lib/irb/ruby-lex.rb
elsif block_given?
@input = block
else
@input = Proc.new{@io.gets}
@input = proc { @io.gets }
end
end
......
if p.respond_to?(:call)
@prompt = p
else
@prompt = Proc.new{print p}
@prompt = proc { print p }
end
end
......
end
@OP.def_rule("=begin",
proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
proc { |op, io| @prev_char_no == 0 && peek(0) =~ /\s/ }) do
|op, io|
@ltype = "="
until getc == "\n"; end
......
Token(TkOPASGN, $1)
end
@OP.def_rule("+@", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("+@", proc { |op, io| @lex_state == EXPR_FNAME }) do
|op, io|
@lex_state = EXPR_ARG
Token(op)
end
@OP.def_rule("-@", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("-@", proc { |op, io| @lex_state == EXPR_FNAME }) do
|op, io|
@lex_state = EXPR_ARG
Token(op)
......
Token("~")
end
@OP.def_rule("~@", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("~@", proc { |op, io| @lex_state == EXPR_FNAME }) do
|op, io|
@lex_state = EXPR_BEG
Token("~")
......
Token(tk_c)
end
@OP.def_rule("[]", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("[]", proc { |op, io| @lex_state == EXPR_FNAME }) do
|op, io|
@lex_state = EXPR_ARG
Token("[]")
end
@OP.def_rule("[]=", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("[]=", proc { |op, io| @lex_state == EXPR_FNAME }) do
|op, io|
@lex_state = EXPR_ARG
Token("[]=")
lib/matrix.rb
size = row_count
last = size - 1
a = to_a
no_pivot = Proc.new{ return 0 }
no_pivot = proc { return 0 }
sign = +1
pivot = 1
size.times do |k|
lib/rdoc/ruby_lex.rb
elsif block_given?
@input = block
else
@input = Proc.new{@io.gets}
@input = proc { @io.gets }
end
end
......
if p.respond_to?(:call)
@prompt = p
else
@prompt = Proc.new{print p}
@prompt = proc { print p }
end
end
......
end
@OP.def_rule("=begin",
proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
proc { |op, io| @prev_char_no == 0 && peek(0) =~ /\s/ }) do
|op, io|
@ltype = "="
res = ''
......
Token(TkOPASGN, $1)
end
@OP.def_rule("+@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
@OP.def_rule("+@", proc { |op, io| @lex_state == :EXPR_FNAME }) do
|op, io|
@lex_state = :EXPR_ARG
Token(op)
end
@OP.def_rule("-@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
@OP.def_rule("-@", proc { |op, io| @lex_state == :EXPR_FNAME }) do
|op, io|
@lex_state = :EXPR_ARG
Token(op)
......
Token("~")
end
@OP.def_rule("~@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
@OP.def_rule("~@", proc { |op, io| @lex_state == :EXPR_FNAME }) do
|op, io|
@lex_state = :EXPR_BEG
Token("~")
......
Token tk_c
end
@OP.def_rule("[]", proc{|op, io| @lex_state == :EXPR_FNAME}) do
@OP.def_rule("[]", proc { |op, io| @lex_state == :EXPR_FNAME }) do
|op, io|
@lex_state = :EXPR_ARG
Token("[]")
end
@OP.def_rule("[]=", proc{|op, io| @lex_state == :EXPR_FNAME}) do
@OP.def_rule("[]=", proc { |op, io| @lex_state == :EXPR_FNAME }) do
|op, io|
@lex_state = :EXPR_ARG
Token("[]=")
......
end
end
# @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
# @OP.def_rule("def", proc { |op, io| /\s/ =~ io.peek(0) }) do
# |op, io|
# @indent += 1
# @lex_state = :EXPR_FNAME
lib/rss/0.9.rb
@rss.do_validate = @do_validate
@rss.xml_stylesheets = @xml_stylesheets
@last_element = @rss
pr = Proc.new do |text, tags|
pr = proc do |text, tags|
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
end
@proc_stack.push(pr)
lib/rss/1.0.rb
@rss.do_validate = @do_validate
@rss.xml_stylesheets = @xml_stylesheets
@last_element = @rss
pr = Proc.new do |text, tags|
pr = proc do |text, tags|
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
end
@proc_stack.push(pr)
lib/rss/atom.rb
@rss.lang = attrs["xml:lang"]
@rss.base = attrs["xml:base"]
@last_element = @rss
pr = Proc.new do |text, tags|
pr = proc do |text, tags|
@rss.validate_for_stream(tags) if @do_validate
end
@proc_stack.push(pr)
......
@rss.lang = attrs["xml:lang"]
@rss.base = attrs["xml:base"]
@last_element = @rss
pr = Proc.new do |text, tags|
pr = proc do |text, tags|
@rss.validate_for_stream(tags) if @do_validate
end
@proc_stack.push(pr)
lib/rss/maker/base.rb
end
[
["link", "href", Proc.new {|target,| "#{target}.href = 'self'"}],
["link", "href", proc { |target| "#{target}.href = 'self'" }],
["author", "name"],
["contributor", "name"],
].each do |name, attribute, additional_setup_maker|
......
[
["author", "name"],
["link", "href", Proc.new {|target,| "#{target}.href = 'alternate'"}],
["link", "href", proc { |target| "#{target}.href = 'alternate'" }],
["contributor", "name"],
].each do |name, attribute|
def_classed_elements(name, attribute)
lib/rss/parser.rb
element_attrs)
previous << next_element if previous
@last_xml_element = next_element
pr = Proc.new do |text, tags|
pr = proc do |text, tags|
if previous
@last_xml_element = previous
else
......
end
def start_get_text_element(tag_name, prefix, ns, required_uri)
pr = Proc.new do |text, tags|
pr = proc do |text, tags|
setter = self.class.setter(required_uri, tag_name)
if setter and @last_element.respond_to?(setter)
if @do_validate
......
@last_element.parent = previous if klass.need_parent?
@xml_child_mode = @last_element.have_xml_content?
Proc.new do |text, tags|
proc do |text, tags|
p(@last_element.class) if DEBUG
if @xml_child_mode
@last_element.content = @xml_element.to_s
......
def setup_next_element_in_unknown_element
current_element, @last_element = @last_element, nil
Proc.new {@last_element = current_element}
proc { @last_element = current_element }
end
end
lib/webrick/httprequest.rb
# Returns the request body.
def body(&block) # :yields: body_chunk
block ||= Proc.new{|chunk| @body << chunk }
block ||= proc { |chunk| @body << chunk }
read_body(@socket, block)
@body.empty? ? nil : @body
end
    (1-1/1)