Class: Wedding::Ceremony

Inherits:
Object
  • Object
show all
Defined in:
lib/wedding/ceremony.rb

Overview

The magic happens here Sing, dance, eat and enjoy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Ceremony

Time to set the things in the right direction Groom, bride, location, date and event schedule.

Parameters:

  • config (Hash)

    configuration object for the constructor



14
15
16
17
18
19
20
21
22
# File 'lib/wedding/ceremony.rb', line 14

def initialize(config)
  @groom = Wedding::Groom.new(config)
  @bride = Wedding::Bride.new(config)
  @location = config[:location]
  @date = Date.parse(config[:date])
  @event_schedule = config[:event_schedule]

  @artii = Artii::Base.new :font => 'slant'
end

Instance Attribute Details

#brideObject (readonly)

We need to access what we have set earlier



25
26
27
# File 'lib/wedding/ceremony.rb', line 25

def bride
  @bride
end

#dateObject (readonly)

We need to access what we have set earlier



25
26
27
# File 'lib/wedding/ceremony.rb', line 25

def date
  @date
end

#event_scheduleObject (readonly)

We need to access what we have set earlier



25
26
27
# File 'lib/wedding/ceremony.rb', line 25

def event_schedule
  @event_schedule
end

#groomObject (readonly)

We need to access what we have set earlier



25
26
27
# File 'lib/wedding/ceremony.rb', line 25

def groom
  @groom
end

#locationObject (readonly)

Lets have a more readable format of coordinates method with a URL to google maps



25
26
27
# File 'lib/wedding/ceremony.rb', line 25

def location
  @location
end

Instance Method Details

#coordinatesObject

Venue coordinates



28
29
30
# File 'lib/wedding/ceremony.rb', line 28

def coordinates
  @location
end

#days_leftObject

Number of days left



39
40
41
# File 'lib/wedding/ceremony.rb', line 39

def days_left
  (date - Date.today)
end

#eventsObject

Event schedule



44
45
46
# File 'lib/wedding/ceremony.rb', line 44

def events
  @event_schedule.join("\n")
end

#invitationObject

Forms a pretty invitation card for the wedding



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/wedding/ceremony.rb', line 49

def invitation
  invitation = %Q[
#{print_ganesha.color(:green)}
========= Wedding invitation ==========

#{@artii.asciify(groom.name).color(:blue)}  
with
#{@artii.asciify(bride.name).color(:blue)}


Hi #{`whoami`.strip.capitalize}

We are getting married on #{date.strftime("%d %B %y")}. It will
be a great pleasure for us to have your presence
in the wedding ceremony.

Event schedule:

#{events}

Pack your bags! Only #{days_left.to_s.color(:red)} days left.
  ]

rescue StandardError => e

  invitation = %Q[
========= Wedding invitation ==========

Looks like something went wrong here, did you you fake
the invitation?

  ]

end

In Hindu mythology it is a custom to start anything new worshipping lord Ganesha en.wikipedia.org/wiki/Ganesha



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/wedding/ceremony.rb', line 87

def print_ganesha
  ganesh = %Q[
             _.!._             
            /O*@*O\\           
          <\\@(_)@/>           
  ,;,   .--;`     `;--.   ,    
  O@O_ /   |d     b|   \\ _hnn 
  | `/ \\   |       |   / \\` |
  &&&&  :##;\\     /;##;  &&&& 
  |  \\ / `##/|   |##'  \\ /  |
  \\   %%%%`</|   |#'`%%%%   / 
   '._|_ \\   |   |'  / _|_.'  
     _/  /   \\   \\   \\  \\  
    / (\\(     '.  '-._&&&&    
   (  ()##,    o'--.._`\\-)    
    '-():`##########'()()()    
     /:::::/()`Y`()\\:::::\\   
     \\::::( () | () )::::/    
      `"""`\\().'.()/'"""`     
      ]
end

#rsvpObject

RSVP for the event



110
111
112
113
114
115
116
# File 'lib/wedding/ceremony.rb', line 110

def rsvp
  invitation = %Q[
You can RSVP to the event by sending an email to
#{groom.name.color(:blue)} (#{groom.email.color(:green)}) 
or #{bride.name.color(:blue)} (#{bride.email.color(:green)})
  ]
end