Class: CanvasConnect::MeetingArchive

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas_connect/meeting_archive.rb

Constant Summary collapse

ATTRIBUTES =
[:name, :url_path, :date_begin, :date_end, :date_modified, :duration, :date_created]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(archive) ⇒ MeetingArchive

Public: Create a new MeetingArchive.

archive - A Nokogiri::XML representation of the Connect response to to sco-contents action.



35
36
37
38
# File 'lib/canvas_connect/meeting_archive.rb', line 35

def initialize(archive)
  @attr_cache = {}
  @archive = archive
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



44
45
46
47
# File 'lib/canvas_connect/meeting_archive.rb', line 44

def method_missing(meth, *args, &block)
  return super unless ATTRIBUTES.include?(meth.to_sym)
  @attr_cache[meth] ||= @archive.at_xpath("//#{meth.to_s.dasherize}").try(:text)
end

Instance Attribute Details

#meeting_idObject

Returns the value of attribute meeting_id.



23
24
25
# File 'lib/canvas_connect/meeting_archive.rb', line 23

def meeting_id
  @meeting_id
end

Class Method Details

.retrieve(meeting_id, client = CanvasConnect.client) ⇒ Object



25
26
27
28
29
30
# File 'lib/canvas_connect/meeting_archive.rb', line 25

def self.retrieve(meeting_id, client = CanvasConnect.client)
  result = client.sco_contents(sco_id: meeting_id, filter_icon: 'archive')
  result.xpath('/results/scos/sco').map do |archive|
    MeetingArchive.new(archive)
  end
end

Instance Method Details

#idObject



40
41
42
# File 'lib/canvas_connect/meeting_archive.rb', line 40

def id
  @archive.attr('sco-id')
end