Class: FakeGit::Priv::Object
- Inherits:
-
Object
- Object
- FakeGit::Priv::Object
- Defined in:
- lib/fake_git/priv/object.rb
Defined Under Namespace
Classes: TypeError
Constant Summary collapse
- ALLOWED_TYPES =
["blob", "tree", "commit", "tag", nil]
- OBJ_PATH =
".fakegit/objects"
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#date ⇒ Object
Returns the value of attribute date.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#index ⇒ Object
Returns the value of attribute index.
-
#message ⇒ Object
Returns the value of attribute message.
-
#path ⇒ Object
Returns the value of attribute path.
-
#tree ⇒ Object
Returns the value of attribute tree.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type: nil, content: nil, index: nil, path: nil, file_name: nil, message: nil, tree: nil, date: nil) ⇒ Object
constructor
A new instance of Object.
- #write! ⇒ Object
Constructor Details
#initialize(type: nil, content: nil, index: nil, path: nil, file_name: nil, message: nil, tree: nil, date: nil) ⇒ Object
Returns a new instance of Object.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fake_git/priv/object.rb', line 8 def initialize(type: nil, content: nil, index: nil, path: nil, file_name: nil, message: nil, tree: nil, date: nil) @type = type @content = content @index = index @path = path @file_name = file_name @message = @tree = tree @date = Time.now raise TypeError.new("#{type} must be one of #{ALLOWED_TYPES}") if !ALLOWED_TYPES.include?(@type) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def content @content end |
#date ⇒ Object
Returns the value of attribute date.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def date @date end |
#file_name ⇒ Object
Returns the value of attribute file_name.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def file_name @file_name end |
#index ⇒ Object
Returns the value of attribute index.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def index @index end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def @message end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def path @path end |
#tree ⇒ Object
Returns the value of attribute tree.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def tree @tree end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/fake_git/priv/object.rb', line 6 def type @type end |
Instance Method Details
#write! ⇒ Object
28 29 30 31 32 |
# File 'lib/fake_git/priv/object.rb', line 28 def write! write_top_index write_new_index puts index end |