Class: Gitrob::Github::Blob
- Inherits:
-
Object
- Object
- Gitrob::Github::Blob
- Defined in:
- lib/gitrob/github/blob.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #dirname ⇒ Object
- #extension ⇒ Object
- #filename ⇒ Object
-
#initialize(path, size, repository) ⇒ Blob
constructor
A new instance of Blob.
- #save_to_database!(organization, repository) ⇒ Object
- #to_model(organization, repository) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(path, size, repository) ⇒ Blob
Returns a new instance of Blob.
6 7 8 |
# File 'lib/gitrob/github/blob.rb', line 6 def initialize(path, size, repository) @path, @size, @repository = path, size, repository end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/gitrob/github/blob.rb', line 4 def path @path end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
4 5 6 |
# File 'lib/gitrob/github/blob.rb', line 4 def repository @repository end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/gitrob/github/blob.rb', line 4 def size @size end |
Instance Method Details
#dirname ⇒ Object
18 19 20 |
# File 'lib/gitrob/github/blob.rb', line 18 def dirname File.dirname(path) end |
#extension ⇒ Object
10 11 12 |
# File 'lib/gitrob/github/blob.rb', line 10 def extension File.extname(path)[1..-1] end |
#filename ⇒ Object
14 15 16 |
# File 'lib/gitrob/github/blob.rb', line 14 def filename File.basename(path) end |
#save_to_database!(organization, repository) ⇒ Object
36 37 38 |
# File 'lib/gitrob/github/blob.rb', line 36 def save_to_database!(organization, repository) self.to_model(organization, repository).tap { |m| m.save } end |
#to_model(organization, repository) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/gitrob/github/blob.rb', line 26 def to_model(organization, repository) repository.blobs.new( :path => self.path, :filename => self.filename, :extension => self.extension, :size => self.size, :organization => organization ) end |
#url ⇒ Object
22 23 24 |
# File 'lib/gitrob/github/blob.rb', line 22 def url "https://github.com/#{URI.escape(repository.owner)}/#{URI.escape(repository.name)}/blob/master/#{URI.escape(path)}" end |