Class: CanvasWebex::Training

Inherits:
WebexSession show all
Defined in:
lib/canvas_webex/training.rb

Constant Summary collapse

ATTRIBUTES =
[:session_key, :conf_name, :start_date, :status]

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WebexSession

#host_url, #join_url, parse_time_stamp, recordings

Constructor Details

#initialize(training_xml) ⇒ Training

Public: Create a new Training

training_xml - The xml returned for a training (must already exist).



41
42
43
44
# File 'lib/canvas_webex/training.rb', line 41

def initialize(training_xml)
  @attr_cache = {}
  @xml = training_xml
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/canvas_webex/training.rb', line 46

def method_missing(meth, *args, &block)
  if ATTRIBUTES.include?(meth)
    @attr_cache[meth] ||= @xml.at_xpath("//*[contains(translate(name(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), '#{meth.to_s.camelcase(:lower).downcase}')]").try(:text)
  else
    super
  end
end

Class Method Details

.create(session_name, options = {}, client = CanvasWebex.client) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/canvas_webex/training.rb', line 30

def self.create(session_name, options = {}, client = CanvasWebex.client)
  if response = client.create_training_session(session_name, options)
    if session_key = response.at_xpath('//sessionkey').try(:text)
      retrieve(session_key, client)
    end
  end
end

.retrieve(session_key, client = CanvasWebex.client) ⇒ Object



24
25
26
27
28
# File 'lib/canvas_webex/training.rb', line 24

def self.retrieve(session_key, client = CanvasWebex.client)
  if response = client.get_training_session(session_key)
    Training.new(Nokogiri::XML(response.to_xml))
  end
end