Class: Hubba::Stats::HistoryItem

Inherits:
Object
  • Object
show all
Defined in:
lib/hubba/reports/stats.rb

Overview

build history items (structs)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, stars:, forks:) ⇒ HistoryItem

Returns a new instance of HistoryItem.



113
114
115
116
117
118
# File 'lib/hubba/reports/stats.rb', line 113

def initialize( date:, stars:, forks: )
  @date  = date
  @stars = stars
  @forks = forks
  @next  = nil
end

Instance Attribute Details

#dateObject (readonly)

read-only attributes



110
111
112
# File 'lib/hubba/reports/stats.rb', line 110

def date
  @date
end

#forksObject (readonly)

read-only attributes



110
111
112
# File 'lib/hubba/reports/stats.rb', line 110

def forks
  @forks
end

#nextObject

read/write attributes (for double linked list/nodes/items)



111
112
113
# File 'lib/hubba/reports/stats.rb', line 111

def next
  @next
end

#prevObject

read/write attributes (for double linked list/nodes/items)



111
112
113
# File 'lib/hubba/reports/stats.rb', line 111

def prev
  @prev
end

#starsObject (readonly)

read-only attributes



110
111
112
# File 'lib/hubba/reports/stats.rb', line 110

def stars
  @stars
end

Instance Method Details

#append(item) ⇒ Object

link items (append item at the end/tail)



121
122
123
124
# File 'lib/hubba/reports/stats.rb', line 121

def append( item )
  @next = item
  item.prev = self
end

#diff_daysObject



126
127
128
129
130
131
132
133
# File 'lib/hubba/reports/stats.rb', line 126

def diff_days
  if @next
    ## note: use jd=julian days for calculation
    @date.jd - @next.date.jd
  else
    nil   ## last item (tail)
  end
end

#diff_starsObject



135
136
137
138
139
140
141
# File 'lib/hubba/reports/stats.rb', line 135

def diff_stars
  if @next
    @stars - @next.stars
  else
    nil   ## last item (tail)
  end
end