Class: Gitmain::Blob
- Inherits:
-
Object
- Object
- Gitmain::Blob
- Defined in:
- lib/gitmain/blob.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #changed_attributes ⇒ Object
- #content ⇒ Object
- #content=(value) ⇒ Object
- #file_name ⇒ Object
-
#initialize(repository, id, path = nil, name = nil) ⇒ Blob
constructor
A new instance of Blob.
Constructor Details
#initialize(repository, id, path = nil, name = nil) ⇒ Blob
Returns a new instance of Blob.
5 6 7 8 9 10 11 12 |
# File 'lib/gitmain/blob.rb', line 5 def initialize(repository, id, path = nil, name = nil) raise ArgumentError, 'provide a valid repository' unless repository.kind_of?(Gitmain::Repository) raise ArgumentError, 'provide a valid blob id' unless id.to_s.match(/\A[0-9a-f]{40}\z/) @repository = repository @id = id @path = path @name = name end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/gitmain/blob.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/gitmain/blob.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/gitmain/blob.rb', line 3 def path @path end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
3 4 5 |
# File 'lib/gitmain/blob.rb', line 3 def repository @repository end |
Instance Method Details
#changed_attributes ⇒ Object
14 15 16 |
# File 'lib/gitmain/blob.rb', line 14 def changed_attributes @changed_attributes ||= {} end |
#content ⇒ Object
18 19 20 |
# File 'lib/gitmain/blob.rb', line 18 def content @content ||= _blob&.content end |
#content=(value) ⇒ Object
22 23 24 25 |
# File 'lib/gitmain/blob.rb', line 22 def content=(value) changed_attributes[:content] = content @content = value end |
#file_name ⇒ Object
27 28 29 |
# File 'lib/gitmain/blob.rb', line 27 def file_name File.join(*[path, name].map(&:to_s).reject(&:empty?)) end |