Class: ArchiveOrgLinkGrabber::Links

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/extract_urls.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lnks) ⇒ Links

Returns a new instance of Links.



21
22
23
# File 'lib/utils/extract_urls.rb', line 21

def initialize(lnks)
  self.links = lnks
end

Instance Attribute Details

Returns the value of attribute links.



19
20
21
# File 'lib/utils/extract_urls.rb', line 19

def links
  @links
end

Instance Method Details

#add_archive_orgObject



34
35
36
37
# File 'lib/utils/extract_urls.rb', line 34

def add_archive_org
  links.map! { |l| 'https://archive.org' + l }
  self
end

#add_leading_dashObject



39
40
41
42
# File 'lib/utils/extract_urls.rb', line 39

def add_leading_dash
  links.map! { |l| '- ' + l }
  self
end


25
26
27
# File 'lib/utils/extract_urls.rb', line 25

def add_links(lnks)
  self.links << lnks
end

#only_mp3sObject



29
30
31
32
# File 'lib/utils/extract_urls.rb', line 29

def only_mp3s
  links.delete_if { |l| !l.match(/\.mp3$/i) }
  self
end

#yaml_formattedObject



44
45
46
# File 'lib/utils/extract_urls.rb', line 44

def yaml_formatted
  only_mp3s.add_archive_org.add_leading_dash.links
end