class IMDB::Data::Credit

Attributes

tr[R]

Public Class Methods

new(noko_tr) click to toggle source
# File lib/imdb-html/data/credit.rb, line 6
def initialize noko_tr
        @tr = noko_tr
end

Public Instance Methods

name() click to toggle source
# File lib/imdb-html/data/credit.rb, line 11
def name
        tr.at('td.nm').text
end
nm() click to toggle source
# File lib/imdb-html/data/credit.rb, line 14
def nm
        tr.at('td.nm a')["href"][ NM ]
end
roles() click to toggle source
# File lib/imdb-html/data/credit.rb, line 17
def roles
        roles, parens = tr.at('td.char').inner_html.split( SPLIT_BEFORE_PAREN )
        roles = "" unless roles
        parens = "" unless parens

        etc = parens.scan( IN_PARENS ).flatten
        roles.split(" / ").map do |role|

                name_of_role = role.gsub(%r{<.*?>},"").strip
                role_ch = role[ CH ]

                hash = {:char => name_of_role}
                hash[:ch] = role_ch.to_i if role_ch
                etc.each{ |thing| hash[ thing.to_sym ] = true }
                hash
        end
end