Class: Idler::Descriptions
- Inherits:
-
Object
- Object
- Idler::Descriptions
- Defined in:
- lib/idler/descriptions.rb
Instance Method Summary collapse
- #add_branch(branch_name = nil) ⇒ Object
- #add_desc(branch_name = nil, desc = "") ⇒ Object
- #add_detail(branch_name = nil, detail = "") ⇒ Object
- #info ⇒ Object
-
#initialize ⇒ Descriptions
constructor
A new instance of Descriptions.
Constructor Details
#initialize ⇒ Descriptions
Returns a new instance of Descriptions.
4 5 6 |
# File 'lib/idler/descriptions.rb', line 4 def initialize @descriptions = {} end |
Instance Method Details
#add_branch(branch_name = nil) ⇒ Object
8 9 10 11 |
# File 'lib/idler/descriptions.rb', line 8 def add_branch(branch_name = nil) raise NothingBranchNameError if branch_name.nil? @descriptions[branch_name] = {} end |
#add_desc(branch_name = nil, desc = "") ⇒ Object
13 14 15 16 17 |
# File 'lib/idler/descriptions.rb', line 13 def add_desc(branch_name = nil, desc = "") raise NothingBranchNameError if branch_name.nil? raise NotYetAddBranchError unless @descriptions.key?(branch_name) @descriptions[branch_name][:description] = desc end |
#add_detail(branch_name = nil, detail = "") ⇒ Object
19 20 21 22 23 |
# File 'lib/idler/descriptions.rb', line 19 def add_detail(branch_name = nil, detail = "") raise NothingBranchNameError if branch_name.nil? raise NotYetAddBranchError unless @descriptions.key?(branch_name) @descriptions[branch_name][:detail] = detail end |
#info ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/idler/descriptions.rb', line 25 def info puts "--- Branches Info ---" @descriptions.each do |branch, info| print "* \e[1m#{branch}\e[0m" if info[:description] puts " - #{info[:description]}" else print "\n" end puts "#{info[:detail]}\n" if info[:detail] end end |