Class: Faker::Science
Constant Summary collapse
- BRANCHES =
{ empirical: %i[empirical_natural_basic empirical_natural_applied empirical_social_basic empirical_social_applied], formal: %i[formal_basic formal_applied], natural: %i[empirical_natural_basic empirical_natural_applied], social: %i[empirical_social_basic empirical_social_applied], basic: %i[empirical_natural_basic empirical_social_basic formal_basic], applied: %i[empirical_natural_applied empirical_social_applied formal_applied] }.freeze
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.element ⇒ String
Produces the name of a element.
-
.element_state ⇒ String
Produces the state of an element.
-
.element_subcategory ⇒ String
Produces the subcategory of an element.
-
.element_symbol ⇒ String
Produces the symbol of an element.
-
.modifier ⇒ String
Produces a scientifically sounding word.
-
.science(*branches) ⇒ String
Produces a name of a science You can optionally filter by specifying one or more of the following: ‘:empirical, :formal, :natural, :social, :basic, :applied`.
-
.scientist ⇒ String
Produces the name of a scientist.
-
.tool(simple: false) ⇒ String
Produces the name of a scientific tool.
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
.element ⇒ String
Produces the name of a element.
56 57 58 |
# File 'lib/faker/default/science.rb', line 56 def element fetch('science.element') end |
.element_state ⇒ String
Produces the state of an element.
82 83 84 |
# File 'lib/faker/default/science.rb', line 82 def element_state fetch('science.element_state') end |
.element_subcategory ⇒ String
Produces the subcategory of an element.
95 96 97 |
# File 'lib/faker/default/science.rb', line 95 def element_subcategory fetch('science.element_subcategory') end |
.element_symbol ⇒ String
Produces the symbol of an element.
69 70 71 |
# File 'lib/faker/default/science.rb', line 69 def element_symbol fetch('science.element_symbol') end |
.modifier ⇒ String
Produces a scientifically sounding word
122 123 124 |
# File 'lib/faker/default/science.rb', line 122 def modifier fetch('science.modifier') end |
.science(*branches) ⇒ String
Produces a name of a science You can optionally filter by specifying one or more of the following: ‘:empirical, :formal, :natural, :social, :basic, :applied`
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/faker/default/science.rb', line 31 def science(*branches) selected = BRANCHES.values.flatten.uniq branches.each do |branch| selected &= BRANCHES[branch] if BRANCHES.key? branch end raise ArgumentError, 'Filters do not match any sciences' if selected.empty? sciences = [] selected.each do |branch| sciences += translate("faker.science.branch.#{branch}") end sample(sciences) end |
.scientist ⇒ String
Produces the name of a scientist.
108 109 110 |
# File 'lib/faker/default/science.rb', line 108 def scientist fetch('science.scientist') end |
.tool(simple: false) ⇒ String
Produces the name of a scientific tool. By default it uses a science word modifier to generate more diverse data, which can be disabled.
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/faker/default/science.rb', line 140 def tool(simple: false) tool = fetch('science.tool') return tool if simple # Makes sure the modifier are different loop do modifier = self.modifier break unless tool.start_with?(modifier) end "#{modifier} #{tool}" end |