class RecordMedium::Export
Export
methods
Constants
- HOST
Public Class Methods
new(data)
click to toggle source
# File lib/record_medium/export.rb, line 20 def initialize(data) @data = data @data[:timestamp] ||= Time.now.to_i raise ArgumentError, 'No key' unless @data[:key] raise ArgumentError, 'No secret' unless @data[:secret] end
sign(data)
click to toggle source
# File lib/record_medium/export.rb, line 8 def self.sign(data) Digest::MD5.hexdigest( [ data[:key], data[:kind], data[:duration], (data[:projects] ? data[:projects].join : nil), (data[:reports] ? data[:reports].join : nil), data[:timestamp], data[:secret] ].join ) end
Public Instance Methods
iframe()
click to toggle source
# File lib/record_medium/export.rb, line 28 def iframe "<iframe width='#{@data[:width]}' height='#{@data[:height]}' src='#{url}'\ frameborder='0' allowfullscreen></iframe>" end
url()
click to toggle source
# File lib/record_medium/export.rb, line 33 def url "#{HOST}/export/#{@data[:key]}?#{query_string}" end
Private Instance Methods
query_string()
click to toggle source
# File lib/record_medium/export.rb, line 39 def query_string signed = self.class.sign(@data) # drop empty values and convert to query string HTTParty::HashConversions.to_params(@data.merge(key: nil, secret: nil) .compact .merge(sign: signed)) end