Class: Apps::Adapters::Gmail::Markup::Event

Inherits:
BaseContext show all
Defined in:
lib/apps/adapters/gmail/markup/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseContext

#to_script

Methods inherited from Base

#initialize, #to_json, #type

Constructor Details

This class inherits a constructor from Apps::Adapters::Gmail::Markup::Base

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



11
12
13
# File 'lib/apps/adapters/gmail/markup/event.rb', line 11

def end_date
  @end_date
end

#locationObject

Returns the value of attribute location.



11
12
13
# File 'lib/apps/adapters/gmail/markup/event.rb', line 11

def location
  @location
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/apps/adapters/gmail/markup/event.rb', line 11

def name
  @name
end

#start_dateObject

Returns the value of attribute start_date.



11
12
13
# File 'lib/apps/adapters/gmail/markup/event.rb', line 11

def start_date
  @start_date
end

Instance Method Details

#actionsObject



23
24
25
# File 'lib/apps/adapters/gmail/markup/event.rb', line 23

def actions
  @actions ||= []
end

#as_jsonObject



13
14
15
16
17
18
19
20
21
# File 'lib/apps/adapters/gmail/markup/event.rb', line 13

def as_json
  prune super.merge(
    "name" => name,
    "startDate" => start_date,
    "endDate" => end_date,
    "location" => location&.as_json,
    "potentialAction" => actions.map(&:as_json)
  )
end

#build_location(**attrs) ⇒ Object



27
28
29
# File 'lib/apps/adapters/gmail/markup/event.rb', line 27

def build_location(**attrs)
  self.location = Place.new(**attrs)
end

#build_rsvp_actionsObject



31
32
33
# File 'lib/apps/adapters/gmail/markup/event.rb', line 31

def build_rsvp_actions
  actions.clear.concat(%w[Yes No Maybe].map { |response| RsvpAction.new(response: response) })
end