Class: StudioApi::Util
- Inherits:
-
Object
- Object
- StudioApi::Util
- Defined in:
- lib/studio_api/util.rb
Overview
Utility class for handling whole stack of Studio Api
Class Method Summary collapse
- .add_options(request_str, options, first = true) ⇒ Object
-
.configure_studio_connection(connection) ⇒ Array<Class>
Set connection for all StudioApi class, so then you can use it without explicit settings It is useful when program use only one studio credentials.
-
.join_relative_url(*args) ⇒ String
joins relative url for unix servers as URI.join require at least one absolute adress.
Class Method Details
.add_options(request_str, options, first = true) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/studio_api/util.rb', line 31 def self. request_str,,first=true unless .empty? .each do |k,v| separator = first ? "?" : "&" first = false request_str << "#{separator}#{CGI.escape k.to_s}=#{CGI.escape v.to_s}" end end request_str end |
.configure_studio_connection(connection) ⇒ Array<Class>
Set connection for all StudioApi class, so then you can use it without explicit settings It is useful when program use only one studio credentials
13 14 15 16 |
# File 'lib/studio_api/util.rb', line 13 def self.configure_studio_connection connection classes = get_all_usable_class StudioApi classes.each {|c| c.studio_connection = connection} end |
.join_relative_url(*args) ⇒ String
joins relative url for unix servers as URI.join require at least one absolute adress. Especially take care about only one slash otherwise studio returns 404.
23 24 25 26 27 28 29 |
# File 'lib/studio_api/util.rb', line 23 def self.join_relative_url(*args) args.reduce do |base, append| base= base[0..-2] if base.end_with? "/" #remove ending slash in base append = append[1..-1] if append.start_with? "/" #remove leading slash in append "#{base}/#{append}" end end |