Class: GitObjectBrowser::Models::PlainFile
- Inherits:
-
Object
- Object
- GitObjectBrowser::Models::PlainFile
- Defined in:
- lib/git-object-browser/models/plain_file.rb
Instance Method Summary collapse
-
#initialize(input) ⇒ PlainFile
constructor
A new instance of PlainFile.
- #parse ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(input) ⇒ PlainFile
Returns a new instance of PlainFile.
7 8 9 |
# File 'lib/git-object-browser/models/plain_file.rb', line 7 def initialize(input) @in = input end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/git-object-browser/models/plain_file.rb', line 11 def parse @content = @in.read(nil) @content = @content.force_encoding('UTF-8') @content = '(not UTF-8)' unless @content.valid_encoding? @content = @content[0, 3000] + "\n..." if @content.length > 3000 self end |
#to_hash ⇒ Object
19 20 21 |
# File 'lib/git-object-browser/models/plain_file.rb', line 19 def to_hash return { :content => @content } end |