Class: RightGit::Git::Tag
- Inherits:
-
Object
- Object
- RightGit::Git::Tag
- Defined in:
- lib/right_git/git/tag.rb
Overview
A tag in a Git repository.
Defined Under Namespace
Classes: TagError
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Comparison value.
-
#==(other) ⇒ TrueClass|FalseClass
True if equivalent.
-
#delete ⇒ TrueClass
Deletes this tag.
-
#initialize(repo, name) ⇒ Tag
constructor
A new instance of Tag.
-
#to_s ⇒ String
(also: #inspect)
Stringized.
Constructor Details
#initialize(repo, name) ⇒ Tag
Returns a new instance of Tag.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/right_git/git/tag.rb', line 36 def initialize(repo, name) # TEAL FIX: only invalid characters seem to be whitespace and some file # system special characters; need to locate a definitive schema for tag # names. if name.index(/\s|[:\\?*<>\|]/) raise TagError, 'name is invalid' end @repo = repo @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/right_git/git/tag.rb', line 30 def name @name end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
30 31 32 |
# File 'lib/right_git/git/tag.rb', line 30 def repo @repo end |
Instance Method Details
#<=>(other) ⇒ Integer
Returns comparison value.
65 66 67 68 69 70 71 |
# File 'lib/right_git/git/tag.rb', line 65 def <=>(other) if other.kind_of?(self.class) @name <=> other.name else raise ::ArgumentError, 'Wrong type' end end |
#==(other) ⇒ TrueClass|FalseClass
Returns true if equivalent.
55 56 57 58 59 60 61 |
# File 'lib/right_git/git/tag.rb', line 55 def ==(other) if other.kind_of?(self.class) @name == other.name else false end end |
#delete ⇒ TrueClass
Deletes this tag.
76 77 78 79 |
# File 'lib/right_git/git/tag.rb', line 76 def delete @repo.vet_output("tag -d #{@name}") true end |
#to_s ⇒ String Also known as: inspect
Returns stringized.
48 49 50 |
# File 'lib/right_git/git/tag.rb', line 48 def to_s "#{self.class.name}: #{@name.inspect}" end |