Class: PairSee::Card
- Inherits:
-
Object
- Object
- PairSee::Card
- Defined in:
- lib/pair_see/card.rb
Instance Attribute Summary collapse
-
#card_name ⇒ Object
readonly
Returns the value of attribute card_name.
-
#last_date ⇒ Object
readonly
Returns the value of attribute last_date.
-
#number_of_commits ⇒ Object
readonly
Returns the value of attribute number_of_commits.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #duration ⇒ Object
-
#initialize(card_name, commits) ⇒ Card
constructor
A new instance of Card.
- #pretty ⇒ Object
Constructor Details
#initialize(card_name, commits) ⇒ Card
Returns a new instance of Card.
5 6 7 8 9 10 |
# File 'lib/pair_see/card.rb', line 5 def initialize(card_name, commits) @card_name = card_name @number_of_commits = commits.count @first_date = commits.first.date @last_date = commits.last.date end |
Instance Attribute Details
#card_name ⇒ Object (readonly)
Returns the value of attribute card_name.
3 4 5 |
# File 'lib/pair_see/card.rb', line 3 def card_name @card_name end |
#last_date ⇒ Object (readonly)
Returns the value of attribute last_date.
3 4 5 |
# File 'lib/pair_see/card.rb', line 3 def last_date @last_date end |
#number_of_commits ⇒ Object (readonly)
Returns the value of attribute number_of_commits.
3 4 5 |
# File 'lib/pair_see/card.rb', line 3 def number_of_commits @number_of_commits end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 19 |
# File 'lib/pair_see/card.rb', line 16 def ==(other) card_name == other.card_name number_of_commits == other.number_of_commits end |
#duration ⇒ Object
12 13 14 |
# File 'lib/pair_see/card.rb', line 12 def duration (@last_date - @first_date).to_i + 1 end |
#pretty ⇒ Object
21 22 23 24 |
# File 'lib/pair_see/card.rb', line 21 def pretty commits_per_day = ((number_of_commits * 1.0) / duration).round(2) "#{card_name} - - - commits: #{number_of_commits} - - - duration: #{duration} days - - - last commit: #{last_date} - - - commits per day: #{commits_per_day}" end |