Class: BlueConductor::HTTP::Song::Sanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/blue_conductor/http/song/sanitizer.rb

Constant Summary collapse

UNWANTED_CHARS =
%r([^a-zA-Z0-9])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manager) ⇒ Sanitizer

Returns a new instance of Sanitizer.



9
10
11
12
# File 'lib/blue_conductor/http/song/sanitizer.rb', line 9

def initialize(manager)
  @band = manager.band
  @song = manager.song
end

Instance Attribute Details

#bandObject (readonly)

Returns the value of attribute band.



7
8
9
# File 'lib/blue_conductor/http/song/sanitizer.rb', line 7

def band
  @band
end

#songObject (readonly)

Returns the value of attribute song.



7
8
9
# File 'lib/blue_conductor/http/song/sanitizer.rb', line 7

def song
  @song
end

Instance Method Details

#cleanObject



14
15
16
17
# File 'lib/blue_conductor/http/song/sanitizer.rb', line 14

def clean
  @band = strip(@band)
  @song = strip(@song)
end

#strip(str) ⇒ Object



19
20
21
# File 'lib/blue_conductor/http/song/sanitizer.rb', line 19

def strip(str)
  str.downcase.gsub(UNWANTED_CHARS, "-")
end