Class: RapGenius::Annotation
- Inherits:
-
Object
- Object
- RapGenius::Annotation
- Includes:
- Scraper
- Defined in:
- lib/rapgenius/annotation.rb
Constant Summary
Constants included from Scraper
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#song ⇒ Object
readonly
Returns the value of attribute song.
Attributes included from Scraper
Class Method Summary collapse
Instance Method Summary collapse
- #explanation ⇒ Object
-
#initialize(kwargs) ⇒ Annotation
constructor
A new instance of Annotation.
- #lyric ⇒ Object
Methods included from Scraper
Constructor Details
#initialize(kwargs) ⇒ Annotation
Returns a new instance of Annotation.
11 12 13 14 15 16 |
# File 'lib/rapgenius/annotation.rb', line 11 def initialize(kwargs) @id = kwargs.delete(:id) @song = kwargs.delete(:song) @lyric = kwargs.delete(:lyric) self.url = @id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/rapgenius/annotation.rb', line 5 def id @id end |
#song ⇒ Object (readonly)
Returns the value of attribute song.
5 6 7 |
# File 'lib/rapgenius/annotation.rb', line 5 def song @song end |
Class Method Details
.find(id) ⇒ Object
7 8 9 |
# File 'lib/rapgenius/annotation.rb', line 7 def self.find(id) self.new(id: id) end |
Instance Method Details
#explanation ⇒ Object
23 24 25 26 |
# File 'lib/rapgenius/annotation.rb', line 23 def explanation @explanation ||= document.css('meta[property="rap_genius:body"]'). attr('content').to_s end |
#lyric ⇒ Object
18 19 20 21 |
# File 'lib/rapgenius/annotation.rb', line 18 def lyric @lyric ||= document.css('meta[property="rap_genius:referent"]'). attr('content').to_s end |