Module: FilmOn::Services::Groups
- Included in:
- Base
- Defined in:
- lib/film_on/services/groups.rb
Instance Method Summary collapse
-
#convert_groups(json) ⇒ Object
convert_groups: takes the raw JSON and converts it into a nice ruby array of objects.
-
#find_group(id) ⇒ Object
find_group: a convenience method to find the full detail of any given group.
-
#groups(opts = {}) ⇒ Object
groups: will get the entire current list of groups for FilmOn, each group holds an array of ids of associated channels.
Instance Method Details
#convert_groups(json) ⇒ Object
convert_groups: takes the raw JSON and converts it into a nice ruby array of objects
20 21 22 23 |
# File 'lib/film_on/services/groups.rb', line 20 def convert_groups(json) hash = JSON.parse(json) hash.map{|gr| FilmOn::Group.new(gr)} end |
#find_group(id) ⇒ Object
find_group: a convenience method to find the full detail of any given group
28 29 30 31 |
# File 'lib/film_on/services/groups.rb', line 28 def find_group(id) id = id.to_s groups.select{|gr| gr.id == id}.first end |
#groups(opts = {}) ⇒ Object
groups: will get the entire current list of groups for FilmOn, each group holds an array of ids of associated channels
8 9 10 11 12 13 14 15 |
# File 'lib/film_on/services/groups.rb', line 8 def groups(opts={}) return @groups if @groups && !opts[:json] json = get("groups") if opts[:json] return json end @groups = convert_groups(json) end |