Module: BehindTheName

Defined in:
lib/behind_the_name.rb,
lib/behind_the_name/usages.rb,
lib/behind_the_name/version.rb,
lib/behind_the_name/refinements.rb

Defined Under Namespace

Modules: Refinements Classes: Error, ParamError, Usages

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.lookup(name:, exact: 'no') ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/behind_the_name.rb', line 22

def self.lookup(name:, exact: 'no')
  params = {
    name: name,
    exact: normalize_boolean(exact),
    key: api_key
  }

  RestClient.get(uri(:lookup), params: params).parse_as_json
end

.random(gender: nil, usage: nil, number: nil, randomsurname: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/behind_the_name.rb', line 32

def self.random(gender: nil, usage: nil, number: nil, randomsurname: nil)
  usage = validate_and_normalize_usage!(usage, :appendix2)
  validate_number!(number)

  params = {
    gender: normalize_gender(gender),
    usage: usage,
    number: number,
    randomsurname: normalize_boolean(randomsurname),
    key: api_key
  }.compact

  RestClient.get(uri(:random), params: params).parse_as_json
end


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/behind_the_name.rb', line 48

def self.related(name:, usage: nil, gender: nil)
  usage = validate_and_normalize_usage!(usage, :appendix1)

  params = {
    name: name,
    gender: normalize_gender(gender),
    usage: usage,
    key: api_key
  }.compact

  RestClient.get(uri(:related), params: params).parse_as_json
end