Class: CryptoList

Inherits:
Object
  • Object
show all
Includes:
CryptoCalculator::InstanceMethods, FancyText::InstanceMethods
Defined in:
lib/app/crypto_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(crypto_list = nil, future_crypto_list = nil) ⇒ CryptoList

Returns a new instance of CryptoList.



14
15
16
17
# File 'lib/app/crypto_list.rb', line 14

def initialize crypto_list=nil, future_crypto_list=nil
    @crypto_list = CRYPTO_LIST
    @future_crypto_list = CRYPTO_LIST
end

Instance Attribute Details

#crypto_listObject

Returns the value of attribute crypto_list.



11
12
13
# File 'lib/app/crypto_list.rb', line 11

def crypto_list
  @crypto_list
end

#future_crypto_listObject

Returns the value of attribute future_crypto_list.



11
12
13
# File 'lib/app/crypto_list.rb', line 11

def future_crypto_list
  @future_crypto_list
end

Instance Method Details

#list_future_dataObject



50
51
52
53
54
55
# File 'lib/app/crypto_list.rb', line 50

def list_future_data
    get_rate(@future_crypto_list, Player.all[0].exit_date)
    set_player_crypto_list_on_future

    show_list_iterator(@future_crypto_list)
end

#list_past_dataObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/app/crypto_list.rb', line 36

def list_past_data
    get_rate(@crypto_list, Player.all[0].)
    set_player_crypto_list_on_past
    progressbar(
        "Fetching currencies and their rates [:bar]",
        "
        Successfully Fetched!!
        
        " 
    )
    show_list_iterator(@crypto_list)
end

#set_player_crypto_list_on_futureObject



23
24
25
# File 'lib/app/crypto_list.rb', line 23

def set_player_crypto_list_on_future
    Player.all[0].exited_crypto_data = @future_crypto_list
end

#set_player_crypto_list_on_pastObject



19
20
21
# File 'lib/app/crypto_list.rb', line 19

def set_player_crypto_list_on_past
    Player.all[0].past_crypto_list = @crypto_list
end

#show_list_iterator(list_crypto) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/app/crypto_list.rb', line 27

def show_list_iterator(list_crypto)
    pastel = Pastel.new 
    list_crypto.each.with_index(1) do |crypto, index|
        puts pastel.green.bold("
        #{index}. #{crypto[0].upcase}  -  #{crypto[1]}  -  #{crypto[2]} AUD
        ")     
    end
end