class ANN_Media

Public Instance Methods

alt_titles() click to toggle source

@return [Hash] returns hash of titles grouped by language abbreviation

# File lib/ann_wrapper/ann_media.rb, line 52
def alt_titles
        titles = find_info("Alternative title").group_by {|title| title['lang']}
        titles.each do |key, value|
                value.map! do |title|
                        title.content
                end
        end
end
create_methods(obj, dictionary) click to toggle source

create methods inside calling object

# File lib/ann_wrapper/ann_media.rb, line 11
def create_methods(obj, dictionary)
        dictionary.each do |name, key|
                create_method(name) do
                        # find_info in calling object
                        info = find_info(key)
                        return nil if info.nil?
                        info.map do |i|
                                i.content
                        end
                end
        end
end
find_info(obj, key) click to toggle source

@return [Nokogiri::XML::NodeSet] return all info with provided key

# File lib/ann_wrapper/ann_media.rb, line 6
def find_info(obj, key)
        obj.search("info[@type=\"#{key}\"]")
end
genres() click to toggle source

@return [[String]] returns array of genres

# File lib/ann_wrapper/ann_media.rb, line 29
def genres; end
images() click to toggle source

@return [[ANN_Image]] returns array of ANN_Image

# File lib/ann_wrapper/ann_media.rb, line 36
def images
        @images ||= find_info("Picture").xpath("./img").map do |i|
                ANN_Image.new(i['src'], i['width'], i['height'])
        end
end
ratings(obj) click to toggle source

@return [[ANN_Rating]] returns array of ANN_Episode

# File lib/ann_wrapper/ann_media.rb, line 62
def ratings(obj)
        @ratings ||= obj.xpath("./ratings").map do |r|
                ANN_Rating.new(r['nb_votes'], r['weighted_score'], r['bayesian_score'])
        end
end
staff(obj) click to toggle source

@return [[ANN_Staff]] returns array of ANN_Staff

# File lib/ann_wrapper/ann_media.rb, line 43
def staff(obj)
        @staff ||= obj.xpath("./staff").map do |s|
                task = s.at_xpath("task")
                person = s.at_xpath("person")
                ANN_Staff.new(person['id'], task.content, person.content)
        end
end
synopsis() click to toggle source

@return [[String]] returns synopsis

# File lib/ann_wrapper/ann_media.rb, line 27
def synopsis; end
themes() click to toggle source

@return [[String]] returns array of themes

# File lib/ann_wrapper/ann_media.rb, line 31
def themes; end
title() click to toggle source

@return [[String]] returns title(s)

# File lib/ann_wrapper/ann_media.rb, line 25
def title; end
vintage() click to toggle source

@return [[String]] returns array of vintage(s)

# File lib/ann_wrapper/ann_media.rb, line 33
def vintage; end