Class: ForgeryJa::Date

Inherits:
Forgery::Date
  • Object
show all
Defined in:
lib/forgery_ja/forgery_ja/date.rb

Constant Summary collapse

JA_DAYS =

the day name in Japanese

%w{日曜日 月曜日 火曜日 水曜日 木曜日 金曜日 土曜日}
JA_DAYS_ABBR =

the abbreviated form day name in Japanese

%w{      }
JA_MONTHS_WA =

the Japanese name of the month ( “WA” )

%w{睦月 如月 弥生 卯月 皐月 水無月 文月 葉月 長月 神無月 霜月 師走}
JA_MONTHS =

the Japanese name of the month

%w{1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月}

Class Method Summary collapse

Class Method Details

.day_of_week(options = {}) ⇒ Object

Returns a random day name in Japanese

Parameters:

  • Hash

    options

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :abbr (String) — default: false

    短縮形を使うかどうか

Returns:

  • String 曜日を日本語で返します



16
17
18
19
20
21
22
23
24
# File 'lib/forgery_ja/forgery_ja/date.rb', line 16

def self.day_of_week(options={})
  options.reverse_merge!(:abbr => false)

  if options[:abbr]
    JA_DAYS_ABBR.random
  else
    JA_DAYS.random
  end
end

.month(options = {}) ⇒ Object

Returns a random month name in Japanese

Parameters:

  • Hash

    options

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :wa (String) — default: false

    和名を使うかどうか

Returns:

  • String 月の名前を日本語で返します



29
30
31
32
33
34
35
36
37
# File 'lib/forgery_ja/forgery_ja/date.rb', line 29

def self.month(options={})
  options.reverse_merge!(:wa => false)

  if options[:wa]
    JA_MONTHS_WA.random
  else
    JA_MONTHS.random
  end
end