class Cauldron::Solution::One

Public Class Methods

new() click to toggle source
# File lib/cauldron/solution/one.rb, line 9
def initialize

end

Public Instance Methods

successful?(problem) click to toggle source
# File lib/cauldron/solution/one.rb, line 13
def successful?(problem)
  return false unless problem.arguments.first.kind_of?(Array)
  return false unless problem.arguments.first[0] * 2 == problem.response[0]
  return false unless problem.arguments.first[1] * 2 == problem.response[1]
  true    
end
to_ruby(variables) click to toggle source
# File lib/cauldron/solution/one.rb, line 20
def to_ruby(variables)
  sexp =
  [:method_add_block, 
    [:call, 
      [:vcall, 
        [:@ident, variables[0]]
      ], 
      :".", 
      [:@ident, "collect"]
    ], 
    [:brace_block, 
      [:block_var, 
        [:params, 
          [[:@ident, "x"]]
        ]
      ], 
      [
        :binary, 
        [:var_ref, [:@ident, "x"]],
        :*,
        [:@int, "2"]
      ]
    ]
  ] 
  Sorcerer.source(sexp)
end