get session from pool
get customer input (departure, destination, dates, passengers count)
# search for recommendations conforming to customer input
do Fare_TravelBoardSearch
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
# example | |
# date = Date.today | |
# ExchangeWithFallback.new( | |
# SynchronizedRates.new( | |
# DoubleConvertThrough.new('RUB', | |
# InverseRatesFor.new( {from: 'RUB'}, | |
# RatesUpdatedWithFallback.new( | |
# ActiveRecordRates.new(CurrencyRate.where(date: date, bank: 'cbr')), | |
# LazyRates.new { CentralBankOfRussia.new.update_rates(date) } ))))) |
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
require 'rubygems' | |
require 'rspec' | |
describe "nand logic" do | |
# false false true | |
# false true false | |
# true false false | |
# true true false | |
def nand(a, b) |
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
# AND THAT'S WHY: | |
# it's logical that "flattened" array should work the same as original range | |
# but that test fails on ruby1.8.7 | |
# so 1.9 ruby uses search on String#upto, (and String.succ in it) and iterates on all the items in range | |
require 'test/unit' | |
class RangeInclusionTest < Test::Unit::TestCase | |
def test_range_inclusion | |
assert !('a0'..'b9').include?('aa') |
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
#require 'rubygems' | |
#require 'rspec' | |
def evaler(expr) | |
token = expr.shift | |
case token | |
when '*' | |
evaler(expr) * evaler(expr) | |
when '+' | |
evaler(expr) + evaler(expr) |
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
require 'rubygems' | |
require 'rspec' | |
def evaler(expr) | |
token = expr.shift | |
case token | |
when '*' | |
evaler(expr) * evaler(expr) | |
when '+' | |
evaler(expr) + evaler(expr) |
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
# encoding: utf-8 | |
module FetchNested | |
# Fetches deep nested hash value by its dot-separated path | |
# | |
# hash = {'foo' => {'bar' => {'baz' => 3}}} | |
# hash.nested('foo.bar.baz') | |
# => 3 | |
# hash.nested('foo.key') | |
# => nil | |
# hash.nested('foo.key', 5) |
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
# lvalue slicing of Hashes | |
# hash = {foo: 1, bar: 2, baz: 3} | |
# hash[:foo, :bar] == [1, 2] | |
# | |
# hash[:foo, 3] = 6,7 | |
# hash == {foo: 6, bar: 2, baz: 3, 3 => 7} | |
# | |
# strange enough, I haven't noticed any slowdown on rails startup. | |
class Hash | |
alias oldbracket [] |
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
# encoding: utf-8 | |
# параметры от форм приходят в виде string-ов и массивов | |
# этот модуль призван помогать конвертировать значения у обычных аксессоров | |
# тем же способом, что это делает и активрекорд | |
# | |
# пока поддерживается только cast_to_boolean | |
module CastingAccessors | |
def cast_to_boolean accessor | |
define_method "#{accessor}_with_casting=" do |value| |
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
require 'rubygems' | |
require 'rspec' | |
def includes | |
end | |
def includes_only | |
end | |
describe "#includes" do |