Sha256: 537433a2d567f63fe4c09b09530219330a9a6a1a69842b6c48edad30e8246045

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

# encoding: utf-8
module RapGenius
  class Song
    include RapGenius::Scraper

    def self.find(path)
      self.new(path)
    end

    def initialize(path)
      self.url = path
    end


    def artist
      document.css('.song_title a').text
    end

    def title
      document.css('.edit_song_description i').text
    end

    def description
      document.css('.description_body').text
    end

    def images
      document.css('meta[property="og:image"]').
        map { |meta| meta.attr('content') }
    end

    def full_artist
      document.css('meta[property="og:title"]').attr('content').to_s.
        split(" – ").first
    end

    def annotations
      @annotations ||= document.css('.lyrics a').map do |a|
        Annotation.new(
          id: a.attr('data-id').to_s,
          song: self,
          lyric: a.text
        )
      end
    end


  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rapgenius-0.0.2 lib/rapgenius/song.rb