Class: SingleVelocitator

Inherits:
BaseVelocitator show all
Defined in:
lib/gem_velocity/velocitators/single_velocitator.rb

Instance Attribute Summary collapse

Attributes inherited from BaseVelocitator

#date_range, #gem_name, #max_value, #min_value, #root, #versions

Instance Method Summary collapse

Methods inherited from BaseVelocitator

create, #effective_date_range, #effective_days_in_range, #effective_end_time, #effective_max_value, #effective_min_value, #effective_start_time, #graph, #graph_options, #num_downloads, #totals_map_by_version

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(gem_name, version) ⇒ SingleVelocitator

Returns a new instance of SingleVelocitator.



7
8
9
10
11
12
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 7

def initialize(gem_name, version)
  @gem_name = gem_name
  @version = version
  @versions = [version]
  after_init
end

Instance Attribute Details

#versionObject (readonly)

the one passed in for :versions, it’s just [version]



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

def version
  @version
end

Instance Method Details

#default_max_valueObject



22
23
24
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 22

def default_max_value
  downloads_per_day(@version).map {|day,total| total}.max
end

#default_startObject



14
15
16
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 14

def default_start
  time_format_str(Date.parse(time_built))
end

#hide_legend?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 47

def hide_legend?
  true
end

#line_data(start_t = nil, end_t = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 26

def line_data(start_t = nil, end_t = nil)
  range = nil
  if start_t && end_t
    range = compute_day_range_from_start_end(start_t,end_t)
  else
    range = effective_days_in_range
  end

  range.map do |d|
    downloads_per_day(version)[d] || 0
  end
end

#time_builtObject



18
19
20
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 18

def time_built
  super(@version)
end

#titleObject



39
40
41
# File 'lib/gem_velocity/velocitators/single_velocitator.rb', line 39

def title
  "#{gem_name}-#{version}\n(downloads: #{num_downloads})"
end