module FrontHelper def title(title) content_for :title do [title, Setting.title].compact.join(' | ') end end def description(description) content_for :description do description.present? ? description : Setting.description end end def keywords(keywords) content_for :keywords do keywords.present? ? keywords : Setting.keywords end end def og_image(value) content_for(:og_image) { full_path value } end def og_type(value) content_for(:og_type) { value } end def og_url(value) content_for(:og_url) { value } end def full_path(path) "#{request.protocol + request.host_with_port + path.to_s}" end def recently_rated?(rate_data) rate_data && Time.now.to_i - rate_data['rated_at'] < 86400 #- 24 hours end def balance "#{(current_account ? current_account.reload.balance * Bank::SATOSHI_COEFF : 0).to_i} s" end def today_played_games current_account.operating_date == Date.today ? current_account.played_games : 0 end def expected_revenue left_days > 0 ? Setting.all_days_bonus : Setting.one_day_bonus end def left_days account = current_account continuous_days = account.operating_date && account.operating_date >= Date.yesterday ? account.continuous_days : 0 left_days = Setting.days_for_bonus - continuous_days [left_days, 0].max end end