Class: Factory

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/gem_velocity/velocitators/factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#compute_day_range_from_start_end, #earliest_for, #latest_for, #remove_trailing_x, #time_format_str, #time_format_str_small

Constructor Details

#initialize(options) ⇒ Factory

Returns a new instance of Factory.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gem_velocity/velocitators/factory.rb', line 7

def initialize(options)

  # one ver passed
  if options[:gem_name] && options[:version]
    @gem_name = options[:gem_name]
    @version = options[:version]
    @type = type_from_version(@version)
    @versions = self.velocitator.versions
  elsif options[:full_name]
    @gem_name = name_from_full_name(options[:full_name])
    @version = version_from_full_name(options[:full_name])
    @type = type_from_version(@version)
    @versions = self.velocitator.versions
  end
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



5
6
7
# File 'lib/gem_velocity/velocitators/factory.rb', line 5

def gem_name
  @gem_name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/gem_velocity/velocitators/factory.rb', line 5

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/gem_velocity/velocitators/factory.rb', line 5

def version
  @version
end

#versionsObject (readonly)

Returns the value of attribute versions.



5
6
7
# File 'lib/gem_velocity/velocitators/factory.rb', line 5

def versions
  @versions
end

Instance Method Details

#velocitatorObject



23
24
25
26
27
28
29
30
31
# File 'lib/gem_velocity/velocitators/factory.rb', line 23

def velocitator
  if @type == :aggregated
    @velocitator ||= AggregatedVelocitator.new(@gem_name, @version)
  elsif @type == :single
    @velocitator ||= SingleVelocitator.new(@gem_name, @version)
  else
    raise 'no velocitor found to generate!'
  end
end