Class: CliTasks::Viewer
- Inherits:
-
Object
- Object
- CliTasks::Viewer
- Defined in:
- lib/clitasks/viewer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(*args) ⇒ Viewer
constructor
A new instance of Viewer.
- #print ⇒ Object
- #separator ⇒ Object
- #stories ⇒ Object
- #story(s) ⇒ Object
Constructor Details
Class Method Details
.print(*args) ⇒ Object
12 13 14 |
# File 'lib/clitasks/viewer.rb', line 12 def self.print(*args) new(*args).print end |
Instance Method Details
#header ⇒ Object
26 27 28 |
# File 'lib/clitasks/viewer.rb', line 26 def header sprintf(" %-10s | %-20s | %-6s | %-60s | %-s", :status, :id, :points, :name, :tags) end |
#print ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/clitasks/viewer.rb', line 16 def print puts header puts stories.sort_by{|s| s.name }.inject({}){|hash,s| hash.merge( s.status => hash.fetch(s.status, []) << s ) }.map{|status,group| [separator] + group.map{|s| story(s) } } end |
#separator ⇒ Object
30 31 32 |
# File 'lib/clitasks/viewer.rb', line 30 def separator sprintf(" %-10s | %-20s | %-6s | %-60s | %-s", ?-*10, ?-*20, ?-*6, ?-*60, ?-*20) end |
#stories ⇒ Object
38 39 40 |
# File 'lib/clitasks/viewer.rb', line 38 def stories @stories ||= World.instance.stories end |
#story(s) ⇒ Object
34 35 36 |
# File 'lib/clitasks/viewer.rb', line 34 def story(s) sprintf(" %-10s | %-20s | %-6s | %-60s | %-s", s.status, s.id, ?* * s.points.to_i, s.name.slice(0,60), Array(s.).join(', ')) end |