Class: Cauldron::Solution::One
- Inherits:
-
Object
- Object
- Cauldron::Solution::One
- Defined in:
- lib/cauldron/solution/one.rb
Instance Method Summary collapse
-
#initialize ⇒ One
constructor
A new instance of One.
- #successful?(problem) ⇒ Boolean
- #to_ruby(variables) ⇒ Object
Constructor Details
#initialize ⇒ One
Returns a new instance of One.
9 10 11 |
# File 'lib/cauldron/solution/one.rb', line 9 def initialize end |
Instance Method Details
#successful?(problem) ⇒ Boolean
13 14 15 16 17 18 |
# 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) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 |