Class: GitStore::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/git_store/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, id = nil, data = nil) ⇒ Tag

Returns a new instance of Tag.



6
7
8
9
10
11
# File 'lib/git_store/tag.rb', line 6

def initialize(store, id = nil, data = nil)
  @store = store
  @id = id

  parse(data) if data
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#objectObject

Returns the value of attribute object.



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

def object
  @object
end

#storeObject

Returns the value of attribute store.



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

def store
  @store
end

#taggerObject

Returns the value of attribute tagger.



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

def tagger
  @tagger
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/git_store/tag.rb', line 13

def ==(other)
  Tag === other and id == other.id
end

#parse(data) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/git_store/tag.rb', line 17

def parse(data)
  headers, @message = data.split(/\n\n/, 2)

  headers.split(/\n/).each do |header|
    key, value = header.split(/ /, 2)
    case key
    when 'type'
      @type = value

    when 'object'
      @object = store.get(value)

    when 'tagger'
      @tagger = User.parse(value)

    end
  end

  self
end