Class: FunCi::Tui::Animation
- Inherits:
-
Object
- Object
- FunCi::Tui::Animation
- Defined in:
- lib/fun_ci/tui/animation.rb
Constant Summary collapse
- TYPES =
{ failure: { total_frames: 40, priority: 3 }, timeout: { total_frames: 4, priority: 2 }, success: { total_frames: 40, priority: 1 }, stage_pass: { total_frames: 3, priority: 0 } }.freeze
Instance Attribute Summary collapse
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
-
#run_id ⇒ Object
readonly
Returns the value of attribute run_id.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #advance! ⇒ Object
- #finished? ⇒ Boolean
- #has_footer? ⇒ Boolean
- #has_header? ⇒ Boolean
-
#initialize(type:, run_id:, stage: nil) ⇒ Animation
constructor
A new instance of Animation.
- #priority ⇒ Object
- #total_frames ⇒ Object
Constructor Details
#initialize(type:, run_id:, stage: nil) ⇒ Animation
Returns a new instance of Animation.
15 16 17 18 19 20 21 22 |
# File 'lib/fun_ci/tui/animation.rb', line 15 def initialize(type:, run_id:, stage: nil) raise ArgumentError, "Unknown animation type: #{type}" unless TYPES.key?(type) @type = type @run_id = run_id @stage = stage @frame = 0 end |
Instance Attribute Details
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
13 14 15 |
# File 'lib/fun_ci/tui/animation.rb', line 13 def frame @frame end |
#run_id ⇒ Object (readonly)
Returns the value of attribute run_id.
13 14 15 |
# File 'lib/fun_ci/tui/animation.rb', line 13 def run_id @run_id end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
13 14 15 |
# File 'lib/fun_ci/tui/animation.rb', line 13 def stage @stage end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/fun_ci/tui/animation.rb', line 13 def type @type end |
Instance Method Details
#advance! ⇒ Object
24 25 26 |
# File 'lib/fun_ci/tui/animation.rb', line 24 def advance! @frame += 1 end |
#finished? ⇒ Boolean
28 29 30 |
# File 'lib/fun_ci/tui/animation.rb', line 28 def finished? frame >= total_frames end |
#has_footer? ⇒ Boolean
44 45 46 |
# File 'lib/fun_ci/tui/animation.rb', line 44 def %i[failure success].include?(@type) end |
#has_header? ⇒ Boolean
40 41 42 |
# File 'lib/fun_ci/tui/animation.rb', line 40 def has_header? %i[failure timeout success].include?(@type) end |
#priority ⇒ Object
36 37 38 |
# File 'lib/fun_ci/tui/animation.rb', line 36 def priority TYPES[@type][:priority] end |
#total_frames ⇒ Object
32 33 34 |
# File 'lib/fun_ci/tui/animation.rb', line 32 def total_frames TYPES[@type][:total_frames] end |