Sha256: a010aea34ac9ba5547ee5d66b848a8be386bcee33b23ec495c7575f1a6e90ac1

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

module KinomaxParser
  class Movie
    attr_accessor :title

    def initialize(doc)
      @doc = doc
    end

    def id
      @id ||= @doc.attribute('id').text.to_i
    end

    def title
      @title ||= @doc.at_css('name').text
    end

    def length
      @doc.at_css('length').text.to_i
    end

    def description
      @doc.at_css('description').text
    end

    def genres
      @doc.at_css('genres').text
    end

    def rating
      @doc.at_css('rating').text.to_f
    end

    def rating_count
      @doc.at_css('rating').attribute('votes').text.to_i
    end

    def poster
      @doc.at_css('frameUrl').text
    end

    def trailer
      @doc.at_css('trailer').text
    end

    def director
      @doc.at_css('director').text
    end

    def cast
      @doc.at_css('cast').text
    end

    def schedules
      @doc.css('schedule session').map do |schedule|
        {
          session_id: schedule.attribute('id').text.to_i,
          time: schedule.attribute('time').text,
          passed: schedule.attribute('passed').text,
          type: schedule.at_css('type').text,
          plan: schedule.at_css('plan').text,
          hall: schedule.at_css('hall').text,
          price: schedule.at_css('priceRange').text
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kinomax_parser-0.1.0 lib/kinomax_parser/movie.rb