Class: Jugoya::Moon
- Inherits:
-
Object
- Object
- Jugoya::Moon
- Defined in:
- lib/jugoya/moon.rb
Constant Summary collapse
- @@full_phase =
180- @@half_phase =
90- @@crescent_phase =
27
Instance Attribute Summary collapse
-
#phase ⇒ Object
Returns the value of attribute phase.
Instance Method Summary collapse
- #almost_crescent? ⇒ Boolean
- #almost_full? ⇒ Boolean
- #almost_half? ⇒ Boolean
- #crescent? ⇒ Boolean
- #full? ⇒ Boolean
- #half? ⇒ Boolean
-
#initialize(phase = nil) ⇒ Moon
constructor
A new instance of Moon.
- #status ⇒ Object
Constructor Details
#initialize(phase = nil) ⇒ Moon
Returns a new instance of Moon.
8 9 10 |
# File 'lib/jugoya/moon.rb', line 8 def initialize(phase = nil) @phase = phase.to_i end |
Instance Attribute Details
#phase ⇒ Object
Returns the value of attribute phase.
6 7 8 |
# File 'lib/jugoya/moon.rb', line 6 def phase @phase end |
Instance Method Details
#almost_crescent? ⇒ Boolean
32 33 34 |
# File 'lib/jugoya/moon.rb', line 32 def almost_crescent? (@@crescent_phase - 5..@@crescent_phase + 5).include?(@phase) end |
#almost_full? ⇒ Boolean
24 25 26 |
# File 'lib/jugoya/moon.rb', line 24 def almost_full? (@@full_phase - 10..@@full_phase + 10).include?(@phase) end |
#almost_half? ⇒ Boolean
28 29 30 |
# File 'lib/jugoya/moon.rb', line 28 def almost_half? (@@half_phase - 5..@@half_phase + 5).include?(@phase) end |
#crescent? ⇒ Boolean
20 21 22 |
# File 'lib/jugoya/moon.rb', line 20 def crescent? @phase == @@crescent_phase end |
#full? ⇒ Boolean
12 13 14 |
# File 'lib/jugoya/moon.rb', line 12 def full? @phase == @@full_phase end |
#half? ⇒ Boolean
16 17 18 |
# File 'lib/jugoya/moon.rb', line 16 def half? @phase == @@half_phase end |
#status ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/jugoya/moon.rb', line 36 def status case when full? 'full_moon' when half? 'half_moon' when crescent? 'crescent_moon' when almost_full? 'almost_full_moon' when almost_half? 'almost_half_moon' when almost_crescent? 'almost_crescent_moon' else 'oops.. you will not to be able to worship the beautiful moon.' end end |