Module: Plex

Defined in:
lib/plex-ruby.rb,
lib/plex-ruby/show.rb,
lib/plex-ruby/tags.rb,
lib/plex-ruby/part.rb,
lib/plex-ruby/movie.rb,
lib/plex-ruby/media.rb,
lib/plex-ruby/video.rb,
lib/plex-ruby/client.rb,
lib/plex-ruby/parser.rb,
lib/plex-ruby/server.rb,
lib/plex-ruby/stream.rb,
lib/plex-ruby/season.rb,
lib/plex-ruby/library.rb,
lib/plex-ruby/section.rb,
lib/plex-ruby/episode.rb,
lib/plex-ruby/version.rb

Defined Under Namespace

Classes: Client, Episode, Library, Media, Movie, Parser, Part, Role, Season, Section, Server, Show, Stream, Video

Constant Summary

VERSION =
"1.5.1"

Class Method Summary (collapse)

Class Method Details

+ (Object) camelize(string, first_letter_uppercase = false)

Converts ruby style snake case names into the cammel case names that are

used in the Plex APIs. I.E. <tt>play_media</tt> -> <tt>playMedia</tt>


22
23
24
25
26
27
28
# File 'lib/plex-ruby.rb', line 22

def self.camelize(string, first_letter_uppercase = false)
  if first_letter_uppercase
    string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
  else
    string.to_s[0].chr.downcase + camelize(string, true)[1..-1]
  end
end

+ (String) underscore(string)

Converts camel case names that are commonly found in the Plex APIs into ruby friendly names. I.E. playMedia -> play_media



12
13
14
15
16
17
18
# File 'lib/plex-ruby.rb', line 12

def self.underscore(string)
  string.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end