Class: GitObjectBrowser::Models::Ref
- Inherits:
-
Object
- Object
- GitObjectBrowser::Models::Ref
- Defined in:
- lib/git-object-browser/models/ref.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input) ⇒ Ref
constructor
A new instance of Ref.
- #to_hash ⇒ Object
Constructor Details
#initialize(input) ⇒ Ref
Returns a new instance of Ref.
7 8 9 10 11 12 13 14 15 |
# File 'lib/git-object-browser/models/ref.rb', line 7 def initialize(input) @content = input.read(nil) if @content =~ %r{\Aref:\s*(.+)} @ref = $1 elsif @content =~ %r{\A([0-9a-f]{40})} @sha1 = $1 end end |
Class Method Details
.path?(relpath) ⇒ Boolean
25 26 27 28 |
# File 'lib/git-object-browser/models/ref.rb', line 25 def self.path?(relpath) ref_names = %w{HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD CHERRY_PICK_HEAD} return (ref_names.include?(relpath) || relpath =~ %r{\Arefs/}) end |
Instance Method Details
#to_hash ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/git-object-browser/models/ref.rb', line 17 def to_hash return { :ref => @ref, :sha1 => @sha1, :content => @content } end |