Class: DebsFromRepos::ListUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/debsfromrepos/list_url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, suite = '', component = '', lang = nil) ⇒ ListUrl

Returns a new instance of ListUrl.



6
7
8
9
10
11
# File 'lib/debsfromrepos/list_url.rb', line 6

def initialize(url, suite='', component='', lang=nil)
  @url = url
  @suite = suite
  @component = component
  @lang = lang
end

Instance Attribute Details

#componentObject

Returns the value of attribute component.



4
5
6
# File 'lib/debsfromrepos/list_url.rb', line 4

def component
  @component
end

#langObject

Returns the value of attribute lang.



4
5
6
# File 'lib/debsfromrepos/list_url.rb', line 4

def lang
  @lang
end

#suiteObject

Returns the value of attribute suite.



4
5
6
# File 'lib/debsfromrepos/list_url.rb', line 4

def suite
  @suite
end

Instance Method Details

#get_packages_urlObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/debsfromrepos/list_url.rb', line 13

def get_packages_url
  if @suite.empty?
    $stderr.puts "ERROR: the suite was missing"
    return nil
  elsif @component.empty?
    $stderr.puts "ERROR: the component was missing"
    return nil
  end
  unless @url.match(/(http|ftp)s*:\/\/([\S]*)\/.*/)
    $stderr.puts "ERROR: the url format is wrong"
    return nil
  end
  "#{@url}/dists/#{@suite}/#{@component}/binary-i386/Packages.gz"
end

#get_translations_url(lang = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/debsfromrepos/list_url.rb', line 28

def get_translations_url(lang=nil)
  lang = lang ? lang : @lang
  unless lang
    $stderr.puts "ERROR: no language has been selected"
    return nil
  end
  unless lang.match(/^[a-z][a-z]$/)
    $stderr.puts "ERROR: the language is wrong"
    return nil
  end
  "#{@url}/dists/#{@suite}/#{@component}/i18n/Translation-#{lang}.gz"
end