class Senkyoshi::ContentFile
Attributes
id[R]
linkname[R]
name[R]
Public Class Methods
clean_xid(xid)
click to toggle source
Remove leading slash if necessary so that ContentFile.name
will match the Senkyoshi.xid
# File lib/senkyoshi/models/content_file.rb, line 32 def self.clean_xid(xid) if xid.start_with? "/" xid[1..-1] else xid end end
correct_linkname(canvas_file)
click to toggle source
# File lib/senkyoshi/models/content_file.rb, line 40 def self.correct_linkname(canvas_file) canvas_file.file_path.split("/").last end
new(xml)
click to toggle source
# File lib/senkyoshi/models/content_file.rb, line 22 def initialize(xml) @id = xml.xpath("./@id").first.text @linkname = xml.xpath("./LINKNAME/@value").first.text @name = ContentFile.clean_xid xml.xpath("./NAME").first.text end
Public Instance Methods
canvas_conversion(resources, canvas_file = nil)
click to toggle source
# File lib/senkyoshi/models/content_file.rb, line 44 def canvas_conversion(resources, canvas_file = nil) path = if canvas_file canvas_file.file_path else resource = resources.detect_xid(@name) resource.path if resource end query = "?canvas_download=1&canvas_qs_wrap=1" href = "#{FILE_BASE}/#{path}#{query}" %{ <a class="instructure_scribd_file instructure_file_link" title="#{@linkname}" href="#{href}"> #{@linkname} </a> } end