diff --git a/app/models/etf2l_profile.rb b/app/models/etf2l_profile.rb index 12fe75467..c7a998f6c 100644 --- a/app/models/etf2l_profile.rb +++ b/app/models/etf2l_profile.rb @@ -1,43 +1,53 @@ # frozen_string_literal: true +# typed: true class Etf2lProfile + extend T::Sig attr_accessor :json + sig { params(profile_body: String).void } def initialize(profile_body) @json = JSON.parse(profile_body) end + sig { returns(T.nilable(String)) } def name json.dig('player', 'name') end + sig { returns(T::Boolean) } def banned? active_bans.any? end + sig { returns(T.nilable(String)) } def ban_reason return nil if active_bans.none? active_bans.map { |b| b['reason'] }.join(', ') end + sig { returns(T.nilable(String)) } def ban_expires_at return nil if active_bans.none? active_bans.map { |b| Time.at(b['end']).to_date }.join(', ') end + sig { returns(T.nilable(Etf2lProfile)) } def self.fetch(steam_uid) response_body = Etf2lApi.profile(steam_uid) new(response_body) if response_body end + sig { returns(String) } def self.league_name 'ETF2L' end private + sig { returns(T::Array[Hash]) } def active_bans @active_bans ||= begin now = Time.now.to_i diff --git a/app/models/user.rb b/app/models/user.rb index 5a2d9762a..a5aedb690 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -# typed: false +# typed: true class User < ActiveRecord::Base extend T::Sig