Class: Faker::CryptoCoin

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/crypto_coin.rb

Constant Summary collapse

COIN_NAME =
0
ACRONYM =
1
URL_LOGO =
2

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale

Class Method Details

.acronym(coin: coin_array) ⇒ String

Produces a random crypto coin acronym.

Examples:

Faker::CryptoCoin.acronym #=> "BTC"

Returns:

  • (String)

Available since:

  • 1.9.2



32
33
34
# File 'lib/faker/default/crypto_coin.rb', line 32

def acronym(coin: coin_array)
  coin[ACRONYM]
end

.coin_arrayArray<String>

Produces a random crypto coin’s name, acronym and logo in an array.

Examples:

Faker::CryptoCoin.coin_array #=> ["Dash", "DASH", "https://i.imgur.com/2uX91cb.png"]

Returns:

  • (Array<String>)

Available since:

  • 1.9.2



58
59
60
# File 'lib/faker/default/crypto_coin.rb', line 58

def coin_array
  fetch('crypto_coin.coin').split(',').map(&:strip)
end

.coin_hashHash

Produces a random crypto coin’s name, acronym and logo in a hash.

Examples:

Faker::CryptoCoin.coin_hash {:name=>"Ethereum", :acronym=>"ETH", :url_logo=>"https://i.imgur.com/uOPFCXj.png"}

Returns:

  • (Hash)

Available since:

  • 1.9.2



71
72
73
74
75
76
77
78
79
# File 'lib/faker/default/crypto_coin.rb', line 71

def coin_hash
  coin = coin_array

  {
    name: coin_name(coin: coin),
    acronym: acronym(coin: coin),
    url_logo: (coin: coin)
  }
end

.coin_name(coin: coin_array) ⇒ String

Produces a random crypto coin name.

Examples:

Faker::CryptoCoin.coin_name #=> "Bitcoin"

Returns:

  • (String)

Available since:

  • 1.9.2



19
20
21
# File 'lib/faker/default/crypto_coin.rb', line 19

def coin_name(coin: coin_array)
  coin[COIN_NAME]
end

.url_logo(coin: coin_array) ⇒ String

Produces a random crypto coin logo url.

Examples:

Faker::CryptoCoin. #=> "https://i.imgur.com/EFz61Ei.png"

Returns:

  • (String)

Available since:

  • 1.9.2



45
46
47
# File 'lib/faker/default/crypto_coin.rb', line 45

def (coin: coin_array)
  coin[URL_LOGO]
end