Class: Hubba::Stats::HistoryItem
- Inherits:
-
Object
- Object
- Hubba::Stats::HistoryItem
- Defined in:
- lib/hubba/stats.rb
Overview
build history items (structs)
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
read-only attributes.
-
#next ⇒ Object
read/write attributes (for double linked list/nodes/items).
-
#prev ⇒ Object
read/write attributes (for double linked list/nodes/items).
-
#stars ⇒ Object
readonly
read-only attributes.
Instance Method Summary collapse
-
#append(item) ⇒ Object
link items (append item at the end/tail).
- #diff_days ⇒ Object
- #diff_stars ⇒ Object
-
#initialize(date:, stars:) ⇒ HistoryItem
constructor
A new instance of HistoryItem.
Constructor Details
#initialize(date:, stars:) ⇒ HistoryItem
110 111 112 113 114 |
# File 'lib/hubba/stats.rb', line 110 def initialize( date:, stars: ) @date = date @stars = stars @next = nil end |
Instance Attribute Details
#date ⇒ Object (readonly)
read-only attributes
107 108 109 |
# File 'lib/hubba/stats.rb', line 107 def date @date end |
#next ⇒ Object
read/write attributes (for double linked list/nodes/items)
108 109 110 |
# File 'lib/hubba/stats.rb', line 108 def next @next end |
#prev ⇒ Object
read/write attributes (for double linked list/nodes/items)
108 109 110 |
# File 'lib/hubba/stats.rb', line 108 def prev @prev end |
#stars ⇒ Object (readonly)
read-only attributes
107 108 109 |
# File 'lib/hubba/stats.rb', line 107 def stars @stars end |
Instance Method Details
#append(item) ⇒ Object
link items (append item at the end/tail)
117 118 119 120 |
# File 'lib/hubba/stats.rb', line 117 def append( item ) @next = item item.prev = self end |
#diff_days ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/hubba/stats.rb', line 122 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_stars ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/hubba/stats.rb', line 131 def diff_stars if @next @stars - @next.stars else nil ## last item (tail) end end |