Class: AlexaToolbox::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/alexa_toolbox/context.rb

Overview

Handles the session object in requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Context

Returns a new instance of Context.



7
8
9
10
11
# File 'lib/alexa_toolbox/context.rb', line 7

def initialize (context)
  @system = context.key?(:System) ? context[:System] : ""
  @audioplayer = context.key?(:AudioPlayer) ? AlexaToolbox::AudioPlayer.new(context[:AudioPlayer]) : nil
  @json = context
end

Instance Attribute Details

#audioplayerObject (readonly)

Returns the value of attribute audioplayer.



5
6
7
# File 'lib/alexa_toolbox/context.rb', line 5

def audioplayer
  @audioplayer
end

#jsonObject (readonly)

Returns the value of attribute json.



5
6
7
# File 'lib/alexa_toolbox/context.rb', line 5

def json
  @json
end

#systemObject (readonly)

Returns the value of attribute system.



5
6
7
# File 'lib/alexa_toolbox/context.rb', line 5

def system
  @system
end

Instance Method Details

#application_idObject



13
14
15
# File 'lib/alexa_toolbox/context.rb', line 13

def application_id
  return self.system[:application][:applicationId]
end

#device_idObject



21
22
23
# File 'lib/alexa_toolbox/context.rb', line 21

def device_id
  return self.system[:device][:deviceId]
end

#user_idObject



17
18
19
# File 'lib/alexa_toolbox/context.rb', line 17

def user_id
  return self.system[:user][:userId]
end