Module: FFaker::EducationCN

Extended by:
EducationCN, ModuleUtils
Included in:
EducationCN
Defined in:
lib/ffaker/education_cn.rb

Constant Summary collapse

DEGREE_PREFIX =
%w[哲学 经济学 法学 教育学 文学 历史学 理学 工学 农学 医学].freeze
DEGREE_SUFFIX =
%w[学士 硕士 博士].freeze
POSITION =
%w[华南 华北 华东 华中 西南 西北 东北 东南 中国].freeze
SCHOOL_UNI =
%w[大学 学院].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#degreeObject



13
14
15
# File 'lib/ffaker/education_cn.rb', line 13

def degree
  "#{fetch_sample(DEGREE_PREFIX)}#{fetch_sample(DEGREE_SUFFIX)}"
end

#locationObject



21
22
23
24
25
26
27
# File 'lib/ffaker/education_cn.rb', line 21

def location
  case rand(0..2)
  when 0 then fetch_sample(PROVINCE)
  when 1 then fetch_sample(CITY)
  when 2 then fetch_sample(POSITION)
  end
end

#majorObject



17
18
19
# File 'lib/ffaker/education_cn.rb', line 17

def major
  fetch_sample(MAJOR)
end

#schoolObject



29
30
31
32
33
34
35
# File 'lib/ffaker/education_cn.rb', line 29

def school
  case rand(0..2)
  when 0 then "#{location}#{fetch_sample(SCHOOL_TYPE)}#{fetch_sample(SCHOOL_UNI)}"
  when 1 then "#{location}#{fetch_sample(SCHOOL_UNI)}"
  when 2 then "#{location}#{fetch_sample(SCHOOL_TYPE)}#{fetch_sample(SCHOOL_UNI)}#{fetch_sample(CITY)}分校"
  end
end