Class: Gitrb::Tag

Inherits:
GitObject show all
Defined in:
lib/gitrb/tag.rb

Instance Attribute Summary collapse

Attributes inherited from GitObject

#id, #repository

Instance Method Summary collapse

Methods inherited from GitObject

#==, factory, #git_object, inherited

Constructor Details

#initialize(options = {}) ⇒ Tag

Returns a new instance of Tag.


6
7
8
9
# File 'lib/gitrb/tag.rb', line 6

def initialize(options = {})
  super(options)
  parse(options[:data]) if options[:data]
end

Instance Attribute Details

#messageObject

Returns the value of attribute message


4
5
6
# File 'lib/gitrb/tag.rb', line 4

def message
  @message
end

#objectObject

Returns the value of attribute object


4
5
6
# File 'lib/gitrb/tag.rb', line 4

def object
  @object
end

#taggerObject

Returns the value of attribute tagger


4
5
6
# File 'lib/gitrb/tag.rb', line 4

def tagger
  @tagger
end

#tagtypeObject

Returns the value of attribute tagtype


4
5
6
# File 'lib/gitrb/tag.rb', line 4

def tagtype
  @tagtype
end

Instance Method Details

#parse(data) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitrb/tag.rb', line 11

def parse(data)
  headers, @message = data.split("\n\n", 2)
  repository.set_encoding(@message)

  headers.split("\n").each do |header|
    key, value = header.split(' ', 2)
    case key
    when 'type'
      @tagtype = value
    when 'object'
      @object = Reference.new(:repository => repository, :id => repository.set_encoding(value))
    when 'tagger'
      @tagger = User.parse(repository.set_encoding(value))
    end
  end

  self
end