Module: Toji::Progress::BaseProgress
- Includes:
- Progress
- Included in:
- KojiProgress, MoromiProgress, MotoProgress
- Defined in:
- lib/toji/progress/base_progress.rb
Instance Method Summary collapse
- #all_keys ⇒ Object
- #base_time ⇒ Object
- #day_labels ⇒ Object
- #day_offset ⇒ Object
- #days ⇒ Object
- #has_keys ⇒ Object
Instance Method Details
#all_keys ⇒ Object
26 27 28 |
# File 'lib/toji/progress/base_progress.rb', line 26 def all_keys BaseState::KEYS end |
#base_time ⇒ Object
6 7 8 |
# File 'lib/toji/progress/base_progress.rb', line 6 def base_time states&.first&.time&.to_time end |
#day_labels ⇒ Object
22 23 24 |
# File 'lib/toji/progress/base_progress.rb', line 22 def day_labels days.times.map(&:succ).map(&:to_s) end |
#day_offset ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/toji/progress/base_progress.rb', line 10 def day_offset t = base_time if t offset = (t - Time.mktime(t.year, t.month, t.day)).to_i (DAY - date_line + offset) % DAY end end |
#days ⇒ Object
18 19 20 |
# File 'lib/toji/progress/base_progress.rb', line 18 def days ((states&.last&.elapsed_time_with_offset&.to_f + 1) / DAY).ceil end |
#has_keys ⇒ Object
30 31 32 33 34 |
# File 'lib/toji/progress/base_progress.rb', line 30 def has_keys all_keys.select {|k| states.find {|s| s.send(k).present?} } end |