Class: BillboardHot100::Song

Inherits:
Object
  • Object
show all
Defined in:
lib/billboard_hot_100/song.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(song_hash) ⇒ Song

Returns a new instance of Song.



13
14
15
16
17
18
# File 'lib/billboard_hot_100/song.rb', line 13

def initialize(song_hash)
  song_hash.each do |key, value| 
    self.send(:"#{key}=", value)
  end
  @@all << self
end

Instance Attribute Details

#artistObject

Returns the value of attribute artist.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def artist
  @artist
end

#awardObject

Returns the value of attribute award.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def award
  @award
end

#last_weekObject

Returns the value of attribute last_week.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def last_week
  @last_week
end

#lyricsObject

Returns the value of attribute lyrics.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def lyrics
  @lyrics
end

#peak_positionObject

Returns the value of attribute peak_position.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def peak_position
  @peak_position
end

#rankObject

Returns the value of attribute rank.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def rank
  @rank
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def title
  @title
end

#weeks_on_chartObject

Returns the value of attribute weeks_on_chart.



3
4
5
# File 'lib/billboard_hot_100/song.rb', line 3

def weeks_on_chart
  @weeks_on_chart
end

Class Method Details

.allObject



20
21
22
# File 'lib/billboard_hot_100/song.rb', line 20

def self.all
  @@all
end

.create(songs) ⇒ Object



7
8
9
10
11
# File 'lib/billboard_hot_100/song.rb', line 7

def self.create(songs)
  songs.each do |song|
    self.new(song)
  end
end