Class: Rubyist::Gem

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/rubyist.rb

Defined Under Namespace

Classes: Version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Gem

Returns a new instance of Gem.



40
41
42
43
# File 'lib/rubyist.rb', line 40

def initialize hash
  @name, @info, @homepage_uri, @project_uri =
    %w[name info homepage_uri project_uri].map { |k| hash[k] }
end

Instance Attribute Details

#homepage_uriObject (readonly)

Returns the value of attribute homepage_uri.



37
38
39
# File 'lib/rubyist.rb', line 37

def homepage_uri
  @homepage_uri
end

#infoObject (readonly)

Returns the value of attribute info.



37
38
39
# File 'lib/rubyist.rb', line 37

def info
  @info
end

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/rubyist.rb', line 37

def name
  @name
end

#project_uriObject (readonly)

Returns the value of attribute project_uri.



37
38
39
# File 'lib/rubyist.rb', line 37

def project_uri
  @project_uri
end

Instance Method Details

#<=>(other) ⇒ Object



45
46
47
# File 'lib/rubyist.rb', line 45

def <=>(other)
  name <=> other.name
end

#total_downloadsObject



53
54
55
# File 'lib/rubyist.rb', line 53

def total_downloads
  versions.inject(0) { |sum, v| sum + v.downloads }
end

#versionsObject



49
50
51
# File 'lib/rubyist.rb', line 49

def versions
  @versions ||= Gems.versions(name).map { |v| Version.new v }
end