Class: Commit
- Inherits:
-
Object
- Object
- Commit
- Defined in:
- lib/invoices/models/commit.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#msg ⇒ Object
Returns the value of attribute msg.
Instance Method Summary collapse
-
#initialize(line) ⇒ Commit
constructor
A new instance of Commit.
- #parse_date(line) ⇒ Object
- #parse_msg(line) ⇒ Object
Constructor Details
#initialize(line) ⇒ Commit
Returns a new instance of Commit.
3 4 5 6 |
# File 'lib/invoices/models/commit.rb', line 3 def initialize(line) parse_date(line) parse_msg(line) end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/invoices/models/commit.rb', line 2 def date @date end |
#msg ⇒ Object
Returns the value of attribute msg.
2 3 4 |
# File 'lib/invoices/models/commit.rb', line 2 def msg @msg end |
Instance Method Details
#parse_date(line) ⇒ Object
7 8 9 10 |
# File 'lib/invoices/models/commit.rb', line 7 def parse_date(line) = line.split(/> /).last.slice(0, 10).to_i @date = Time.at() # Convert Unix timestamp end |
#parse_msg(line) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/invoices/models/commit.rb', line 11 def parse_msg(line) if line.include?("commit:") @msg = line.split(/commit:/).last.strip.slice(0, 40) elsif line.include?("commit (initial):") @msg = line.split(/commit \(initial\):/).last.strip.slice(0, 40) end end |