Class: BlueConductor::HTTP::Record::Sanitizer

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(producer) ⇒ Sanitizer

Returns a new instance of Sanitizer.



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

def initialize(producer)
  @band = producer.band
  @title = producer.title
end

Instance Attribute Details

#bandObject (readonly)

Returns the value of attribute band.



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

def band
  @band
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#cleanObject



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

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

#strip(str) ⇒ Object



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

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