Class: Faker::Sport

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/sports/sport.rb

Constant Summary

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, translate, unique, with_locale

Class Method Details

.ancient_olympics_sportString

Produces a sport from the ancient olympics.

Examples:

Faker::Sport.ancient_olympics_sport #=> "Pankration"

Returns:

  • (String)

Available since:

  • next



111
112
113
# File 'lib/faker/sports/sport.rb', line 111

def ancient_olympics_sport
  fetch('sport.ancient_olympics')
end

.sport(include_ancient: false, include_unusual: false) ⇒ String

Produces a sport from the modern olympics or paralympics, summer or winter.

Examples:

Faker::Sport.sport #=> "Football"
Faker::Sport.sport(include_ancient: true) #=> "Chariot racing"
Faker::Sport.sport(include_unsual: true) #=> "Flugtag/Birdman"
Faker::Sport.sport(include_ancient:true, include_unusual: true) #=> "Water polo"

Parameters:

  • include_ancient (Boolean) (defaults to: false)

    If true, may produce a sport from the ancient olympics

  • include_unusual (Boolean) (defaults to: false)

    If true, may produce an unusual (definitely not olympic) sport

Returns:

  • (String)

Available since:

  • next



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/faker/sports/sport.rb', line 24

def sport(include_ancient: false, include_unusual: false)
  sports = []
  sports.concat(
    fetch_all('sport.summer_olympics'),
    fetch_all('sport.summer_paralympics'),
    fetch_all('sport.winter_olympics'),
    fetch_all('sport.winter_paralympics')
  )
  sports.concat(fetch_all('sport.ancient_olympics')) if include_ancient
  sports.concat(fetch_all('sport.unusual')) if include_unusual
  sample(sports)
end

.summer_olympics_sportString

Produces a sport from the summer olympics.

Examples:

Faker::Sport.summer_olympics_sport #=> "Archery"

Returns:

  • (String)

Available since:

  • next



46
47
48
# File 'lib/faker/sports/sport.rb', line 46

def summer_olympics_sport
  fetch('sport.summer_olympics')
end

.summer_paralympics_sportString

Produces a sport from the summer paralympics.

Examples:

Faker::Sport.summer_paralympics_sport #=> "Wheelchair Basketball"

Returns:

  • (String)

Available since:

  • next



72
73
74
# File 'lib/faker/sports/sport.rb', line 72

def summer_paralympics_sport
  fetch('sport.summer_paralympics')
end

.unusual_sportString

Produces an unusual sport.

Examples:

Faker::Sport.unusual_sport #=> "Camel Jumping"

Returns:

  • (String)

Available since:

  • next



98
99
100
# File 'lib/faker/sports/sport.rb', line 98

def unusual_sport
  fetch('sport.unusual')
end

.winter_olympics_sportString

Produces a sport from the winter olympics.

Examples:

Faker::Sport.winter_olympics_sport #=> "Bobsleigh"

Returns:

  • (String)

Available since:

  • next



59
60
61
# File 'lib/faker/sports/sport.rb', line 59

def winter_olympics_sport
  fetch('sport.winter_olympics')
end

.winter_paralympics_sportString

Produces a sport from the winter paralympics.

Examples:

Faker::Sport.winter_paralympics_sport #=> "Para Ice Hockey"

Returns:

  • (String)

Available since:

  • next



85
86
87
# File 'lib/faker/sports/sport.rb', line 85

def winter_paralympics_sport
  fetch('sport.winter_paralympics')
end