Module: Etoji
- Defined in:
- lib/etoji.rb,
lib/etoji/jikkan.rb,
lib/etoji/version.rb,
lib/etoji/jyunishi.rb
Defined Under Namespace
Modules: Jikkan, Jyunishi
Classes: Error
Constant Summary
collapse
- VERSION =
"0.2.1"
Class Method Summary
collapse
Class Method Details
.geto(year:, with_prev: false, with_next: false) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/etoji.rb', line 10
def self.geto(year:, with_prev: false, with_next: false)
year_int = self.convert_year(year)
jyunishi_number = ((year_int + 8) % 12 + 1)
current_animal = ::Etoji::Jyunishi.find_by_number(jyunishi_number)
case [with_prev, with_next]
in [true, true]
prev_animal = ::Etoji.geto(year: year_int - 1)
next_animal = ::Etoji.geto(year: year_int + 1)
[prev_animal, current_animal, next_animal]
in [true, false]
prev_animal = ::Etoji.geto(year: year_int - 1)
[prev_animal, current_animal]
in [false, true]
next_animal = ::Etoji.geto(year: year_int + 1)
[current_animal, next_animal]
else
current_animal
end
end
|
.geto_full_string(year:) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/etoji.rb', line 32
def self.geto_full_string(year:)
year_int = self.convert_year(year)
jikkan_number = ((year_int + 6) % 10 + 1)
current_kan = ::Etoji::Jikkan.find_by_number(jikkan_number)
current_animal = ::Etoji.geto(year: year_int)
[current_kan.character, current_animal.character].join
end
|