Class: Ace::GitCommit::Models::StageResult
- Inherits:
-
Object
- Object
- Ace::GitCommit::Models::StageResult
- Defined in:
- lib/ace/git_commit/models/stage_result.rb
Overview
StageResult represents the outcome of staging a file or set of files
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#file_size ⇒ Object
readonly
Returns the value of attribute file_size.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#human_file_size ⇒ String
Get a human-readable file size.
-
#initialize(file_path:, success:, error_message: nil, file_size: nil, status: nil) ⇒ StageResult
constructor
A new instance of StageResult.
-
#large_file? ⇒ Boolean
Check if this is a large file (>50MB).
-
#status_indicator ⇒ String
Get status indicator emoji.
-
#success? ⇒ Boolean
Check if staging was successful.
-
#to_h ⇒ Hash
Convert to hash for debugging.
Constructor Details
#initialize(file_path:, success:, error_message: nil, file_size: nil, status: nil) ⇒ StageResult
10 11 12 13 14 15 16 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 10 def initialize(file_path:, success:, error_message: nil, file_size: nil, status: nil) @file_path = file_path @success = success = @file_size = file_size @status = status # :modified, :new, :deleted, etc. end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
8 9 10 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 8 def end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 8 def file_path @file_path end |
#file_size ⇒ Object (readonly)
Returns the value of attribute file_size.
8 9 10 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 8 def file_size @file_size end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 8 def status @status end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
8 9 10 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 8 def success @success end |
Instance Method Details
#human_file_size ⇒ String
Get a human-readable file size
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 33 def human_file_size return nil unless @file_size if @file_size < 1024 "#{@file_size} B" elsif @file_size < 1024 * 1024 "#{(@file_size / 1024.0).round(1)} KB" elsif @file_size < 1024 * 1024 * 1024 "#{(@file_size / (1024.0 * 1024.0)).round(2)} MB" else "#{(@file_size / (1024.0 * 1024.0 * 1024.0)).round(2)} GB" end end |
#large_file? ⇒ Boolean
Check if this is a large file (>50MB)
26 27 28 29 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 26 def large_file? return false unless @file_size @file_size > 50 * 1024 * 1024 # 50MB in bytes end |
#status_indicator ⇒ String
Get status indicator emoji
49 50 51 52 53 54 55 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 49 def status_indicator if success? "✓" else "✗" end end |
#success? ⇒ Boolean
Check if staging was successful
20 21 22 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 20 def success? @success end |
#to_h ⇒ Hash
Convert to hash for debugging
59 60 61 62 63 64 65 66 67 |
# File 'lib/ace/git_commit/models/stage_result.rb', line 59 def to_h { file_path: @file_path, success: @success, error_message: , file_size: @file_size, status: @status } end |