Class: Outdated::RubyGems::Spec

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/outdated/ruby_gems/spec.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Spec

Returns a new instance of Spec.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
# File 'lib/outdated/ruby_gems/spec.rb', line 15

def initialize(args)
  @created_at = args[:created_at] or raise ArgumentError, "missing created_at"
  @name = args[:name] or raise ArgumentError, "missing name"

  @prerelease = args[:prerelease]
  raise ArgumentError, "missing prerelease" if @prerelease.nil?

  @version = args[:version] or raise ArgumentError, "missing version"
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



13
14
15
# File 'lib/outdated/ruby_gems/spec.rb', line 13

def created_at
  @created_at
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/outdated/ruby_gems/spec.rb', line 13

def name
  @name
end

#prereleaseObject (readonly)

Returns the value of attribute prerelease.



13
14
15
# File 'lib/outdated/ruby_gems/spec.rb', line 13

def prerelease
  @prerelease
end

#versionObject (readonly)

Returns the value of attribute version.



13
14
15
# File 'lib/outdated/ruby_gems/spec.rb', line 13

def version
  @version
end

Class Method Details

.from_response_object(name, response_object) ⇒ Object



6
7
8
9
10
11
# File 'lib/outdated/ruby_gems/spec.rb', line 6

def self.from_response_object(name, response_object)
  Outdated::RubyGems::Spec.new(created_at: response_object['created_at'].to_time,
                               name: name,
                               prerelease: response_object['prerelease'],
                               version: ::Gem::Version.new(response_object['number']))
end

Instance Method Details

#<=>(other) ⇒ Object



25
26
27
# File 'lib/outdated/ruby_gems/spec.rb', line 25

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