Class: RubyMaat::ChangeRecord
- Inherits:
-
Object
- Object
- RubyMaat::ChangeRecord
- Defined in:
- lib/ruby_maat/change_record.rb
Overview
Represents a single change/modification record from VCS This is the fundamental data structure that flows through the entire pipeline
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
-
#loc_added ⇒ Object
readonly
Returns the value of attribute loc_added.
-
#loc_deleted ⇒ Object
readonly
Returns the value of attribute loc_deleted.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(entity:, author:, date:, revision:, message: nil, loc_added: nil, loc_deleted: nil) ⇒ ChangeRecord
constructor
A new instance of ChangeRecord.
- #to_h ⇒ Object
Constructor Details
#initialize(entity:, author:, date:, revision:, message: nil, loc_added: nil, loc_deleted: nil) ⇒ ChangeRecord
Returns a new instance of ChangeRecord.
9 10 11 12 13 14 15 16 17 |
# File 'lib/ruby_maat/change_record.rb', line 9 def initialize(entity:, author:, date:, revision:, message: nil, loc_added: nil, loc_deleted: nil) @entity = entity @author = @date = date.is_a?(Date) ? date : Date.parse(date) @revision = revision @message = @loc_added = loc_added.to_i if loc_added && (!loc_added.is_a?(Float) || !loc_added.nan?) @loc_deleted = loc_deleted.to_i if loc_deleted && (!loc_deleted.is_a?(Float) || !loc_deleted.nan?) end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def @author end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def date @date end |
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def entity @entity end |
#loc_added ⇒ Object (readonly)
Returns the value of attribute loc_added.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def loc_added @loc_added end |
#loc_deleted ⇒ Object (readonly)
Returns the value of attribute loc_deleted.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def loc_deleted @loc_deleted end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def @message end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
7 8 9 |
# File 'lib/ruby_maat/change_record.rb', line 7 def revision @revision end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/ruby_maat/change_record.rb', line 31 def ==(other) other.is_a?(ChangeRecord) && entity == other.entity && == other. && date == other.date && revision == other.revision end |
#eql?(other) ⇒ Boolean
43 44 45 |
# File 'lib/ruby_maat/change_record.rb', line 43 def eql?(other) self == other end |
#hash ⇒ Object
39 40 41 |
# File 'lib/ruby_maat/change_record.rb', line 39 def hash [entity, , date, revision].hash end |
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby_maat/change_record.rb', line 19 def to_h { entity: entity, author: , date: date, revision: revision, message: , loc_added: loc_added, loc_deleted: loc_deleted } end |