Class: Valanga::Music

Inherits:
Object
  • Object
show all
Defined in:
lib/valanga/music.rb,
lib/valanga/music/base.rb,
lib/valanga/music/collete.rb,
lib/valanga/music/groovin.rb

Defined Under Namespace

Classes: Base, Collete, Groovin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Music

Returns a new instance of Music.



3
4
5
6
7
8
9
10
# File 'lib/valanga/music.rb', line 3

def initialize(document)
  @document = Nokogiri::HTML.parse(document, nil, 'Shift_JIS')
  @music_bk = @document.css("div.music_bk dl")

  unless @music_bk.size == 8 || @music_bk.size == 9
    raise NoMusicInformationError, "Not found music informations"
  end
end

Instance Attribute Details

#music_bkObject (readonly)

Returns the value of attribute music_bk.



12
13
14
# File 'lib/valanga/music.rb', line 12

def music_bk
  @music_bk
end

Instance Method Details

#artistObject



46
47
48
# File 'lib/valanga/music.rb', line 46

def artist
  @artist ||= @document.css("div.music_artist h6").text
end

#basicObject



14
15
16
# File 'lib/valanga/music.rb', line 14

def basic
  Difficulty::Basic.new(self)
end

#colleteObject



30
31
32
# File 'lib/valanga/music.rb', line 30

def collete
  Collete.new(self)
end

#groovinObject



34
35
36
# File 'lib/valanga/music.rb', line 34

def groovin
  Groovin.new(self)
end

#hardObject



22
23
24
# File 'lib/valanga/music.rb', line 22

def hard
  Difficulty::Hard.new(self)
end

#has_special?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/valanga/music.rb', line 38

def has_special?
  music_bk.size == 9
end

#mediumObject



18
19
20
# File 'lib/valanga/music.rb', line 18

def medium
  Difficulty::Medium.new(self)
end

#nameObject



42
43
44
# File 'lib/valanga/music.rb', line 42

def name
  @name ||= @document.css("div.music_dataname h6").text
end

#specialObject



26
27
28
# File 'lib/valanga/music.rb', line 26

def special
  Difficulty::Special.new(self)
end