Files
mruby-mruby/mrbgems/mruby-method/mrblib/method.rb
T
dearblue 9a9e12a129 Add proc composition feature (CRuby-2.6 compatible)
- Proc#<< and Proc#>>
  - Method#<< and Method#>>
2019-01-03 18:16:26 +09:00

29 lines
357 B
Ruby

class Method
def to_proc
m = self
lambda { |*args, &b|
m.call(*args, &b)
}
end
def owner
@owner
end
def receiver
@recv
end
def name
@name
end
def <<(other)
->(*args, &block) { call(other.call(*args, &block)) }
end
def >>(other)
->(*args, &block) { other.call(call(*args, &block)) }
end
end