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, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.acronym(legacy_coin = NOT_GIVEN, coin: coin_array) ⇒ String

Produces a random crypto coin acronym.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.9.2


36
37
38
39
40
41
42
# File 'lib/faker/default/crypto_coin.rb', line 36

def acronym(legacy_coin = NOT_GIVEN, coin: coin_array)
  warn_for_deprecated_arguments do |keywords|
    keywords << :coin if legacy_coin != NOT_GIVEN
  end

  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


70
71
72
# File 'lib/faker/default/crypto_coin.rb', line 70

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


83
84
85
86
87
88
89
90
91
# File 'lib/faker/default/crypto_coin.rb', line 83

def coin_hash
  coin = coin_array

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

.coin_name(legacy_coin = NOT_GIVEN, 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
22
23
24
25
# File 'lib/faker/default/crypto_coin.rb', line 19

def coin_name(legacy_coin = NOT_GIVEN, coin: coin_array)
  warn_for_deprecated_arguments do |keywords|
    keywords << :coin if legacy_coin != NOT_GIVEN
  end

  coin[COIN_NAME]
end

.url_logo(legacy_coin = NOT_GIVEN, 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


53
54
55
56
57
58
59
# File 'lib/faker/default/crypto_coin.rb', line 53

def (legacy_coin = NOT_GIVEN, coin: coin_array)
  warn_for_deprecated_arguments do |keywords|
    keywords << :coin if legacy_coin != NOT_GIVEN
  end

  coin[URL_LOGO]
end