Class: Latest::MRI

Inherits:
Object
  • Object
show all
Defined in:
lib/latest_ruby/rubies/mri.rb

Constant Summary collapse

SOURCE =
'http://ftp.ruby-lang.org/pub/ruby/'
AVAILABLE_EXTS =
['.tar.gz', '.zip', '.tar.bz2']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_ver, retriever) ⇒ MRI

Returns a new instance of MRI.



9
10
11
12
13
# File 'lib/latest_ruby/rubies/mri.rb', line 9

def initialize(short_ver, retriever)
  @short_ver = short_ver
  @retriever = retriever
  @source = SOURCE
end

Instance Attribute Details

#short_verObject (readonly)

Returns the value of attribute short_ver.



7
8
9
# File 'lib/latest_ruby/rubies/mri.rb', line 7

def short_ver
  @short_ver
end

#sourceObject (readonly)

Returns the value of attribute source.



7
8
9
# File 'lib/latest_ruby/rubies/mri.rb', line 7

def source
  @source
end

Instance Method Details



19
20
21
22
23
# File 'lib/latest_ruby/rubies/mri.rb', line 19

def link(ext = '.tar.gz')
  if AVAILABLE_EXTS.include?(ext)
    source + short_ver + '/ruby-' + version.to_s + ext
  end
end

#versionObject



15
16
17
# File 'lib/latest_ruby/rubies/mri.rb', line 15

def version
  @version ||= @retriever.retrieve(self)
end