This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://en.wikipedia.org/wiki/Simple_linear_regression | |
# Exchange.Calc.Regression.run([{1,1},{2,2},{3,3}]) | |
defrecord Exchange.Calc.Regression.Result, products_avg: nil, x_avg: nil, y_avg: nil, x_sqr_avg: nil do | |
def complete?(result) do | |
result.products_avg && result.x_avg && result.y_avg && result.x_sqr_avg | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@image = Image.new | |
respond_with @image | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exists?(attribs) | |
CustomImage.find_by_account_id_and_hash(attribs['account_id'], attribs['id']) | |
end | |
# Memoize using <tt>defined?</tt> | |
def some_method(attribs) | |
return @some_method if defined?(@some_method) | |
@some_method = exists?(attribs) | |
end |