Class: RubygemsDownloads::Gem
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#name ⇒ Object
Returns the value of attribute name.
-
#total_downloads ⇒ Object
Returns the value of attribute total_downloads.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
-
#version_downloads ⇒ Object
Returns the value of attribute version_downloads.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #blank? ⇒ Boolean
-
#initialize {|_self| ... } ⇒ Gem
constructor
A new instance of Gem.
- #state ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Gem
Returns a new instance of Gem.
18 19 20 |
# File 'lib/rubygems_downloads/gem.rb', line 18 def initialize yield self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
5 6 7 |
# File 'lib/rubygems_downloads/gem.rb', line 5 def end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/rubygems_downloads/gem.rb', line 5 def name @name end |
#total_downloads ⇒ Object
Returns the value of attribute total_downloads.
5 6 7 |
# File 'lib/rubygems_downloads/gem.rb', line 5 def total_downloads @total_downloads end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/rubygems_downloads/gem.rb', line 5 def url @url end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/rubygems_downloads/gem.rb', line 5 def version @version end |
#version_downloads ⇒ Object
Returns the value of attribute version_downloads.
5 6 7 |
# File 'lib/rubygems_downloads/gem.rb', line 5 def version_downloads @version_downloads end |
Class Method Details
.from_json(entry) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rubygems_downloads/gem.rb', line 7 def self.from_json(entry) new do |gem| gem.name = entry[:name] gem.total_downloads = entry[:downloads] gem.version_downloads = entry[:version_downloads] gem.version = entry[:version] gem. = entry[:authors] gem.url = entry[:project_uri] end end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 |
# File 'lib/rubygems_downloads/gem.rb', line 37 def ==(other) other.class == self.class && other.state == state end |
#blank? ⇒ Boolean
33 34 35 |
# File 'lib/rubygems_downloads/gem.rb', line 33 def blank? !(name && && total_downloads && version_downloads && version) end |
#state ⇒ Object
41 42 43 |
# File 'lib/rubygems_downloads/gem.rb', line 41 def state instance_variables.map { |variable| instance_variable_get(variable) } end |
#to_h ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubygems_downloads/gem.rb', line 22 def to_h { name: name, author: , total_downloads: total_downloads, version_downloads: version_downloads, version: version, url: url } end |