Class: Shh::Command::ShowHistory
- Inherits:
-
Object
- Object
- Shh::Command::ShowHistory
- Defined in:
- lib/shh/command/show_history.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #completion(text) ⇒ Object
- #execute(name = nil) ⇒ Object
-
#initialize(repository, io) ⇒ ShowHistory
constructor
A new instance of ShowHistory.
Constructor Details
#initialize(repository, io) ⇒ ShowHistory
Returns a new instance of ShowHistory.
4 5 6 7 8 |
# File 'lib/shh/command/show_history.rb', line 4 def initialize repository, io @repository, @io = repository, io @usage = "(<substring>)" @help = "Shows history for a given entry" end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
2 3 4 |
# File 'lib/shh/command/show_history.rb', line 2 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
2 3 4 |
# File 'lib/shh/command/show_history.rb', line 2 def usage @usage end |
Instance Method Details
#completion(text) ⇒ Object
10 11 12 |
# File 'lib/shh/command/show_history.rb', line 10 def completion text @repository.map{|entry| entry['name']}.grep(/^#{text}/).sort || [] end |
#execute(name = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/shh/command/show_history.rb', line 14 def execute name=nil entry = @repository.find { |entry| entry['name'] == name } id = entry ? entry.id : nil first = true @repository.history(id).each do |cs| puts '-------' unless first puts "#{cs.id} #{cs.time}" puts "#{cs.}" puts "#{cs.description}" first = false end end |