class String

Constants

OPERATOR_AFTER

Public Instance Methods

args(*array) click to toggle source
# File lib/core_ext/string.rb, line 10
def args(*array)
  @point_free_args = array
end
r(receiver) click to toggle source
# File lib/core_ext/string.rb, line 5
def r(receiver)
  @point_free_receiver = receiver
end
to_proc() click to toggle source
# File lib/core_ext/string.rb, line 15
def to_proc
  parse_expression(self)
  expression.to_proc
end

Private Instance Methods

expression() click to toggle source
# File lib/core_ext/string.rb, line 23
def expression
  @expression ||= Functionalist::PointFree::Expression.new
end
parse_args(expression, args_string) click to toggle source
# File lib/core_ext/string.rb, line 46
def parse_args(expression, args_string)
  expression.point_free_inject_args(args_string) if args_string
end
parse_expression(exp) click to toggle source
# File lib/core_ext/string.rb, line 27
def parse_expression(exp)
  # carimbar
  exp.strip.split(OPERATOR_AFTER).reverse.each do |sub_exp|
    # descarimbar
    next if parse_functionalist_method(expression, sub_exp)

    _, receiver_string, method_name, args_string = /(\w*\.)?(\w+)(\(.*\))?/.match(sub_exp).to_a
    parse_receiver expression, receiver_string
    parse_args expression, args_string
    expression.send method_name
  end
end
parse_functionalist_method(expression, exp) click to toggle source
# File lib/core_ext/string.rb, line 50
def parse_functionalist_method(expression, exp)

end
parse_receiver(expression, receiver_string) click to toggle source
# File lib/core_ext/string.rb, line 41
def parse_receiver(expression, receiver_string)
  expression.point_free_reciever(receiver_string) if receiver_string
end