Class: GitStatistics::Pipe
- Inherits:
-
Object
- Object
- GitStatistics::Pipe
- Includes:
- Enumerable
- Defined in:
- lib/git_statistics/pipe.rb
Instance Method Summary collapse
- #command ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(command) ⇒ Pipe
constructor
A new instance of Pipe.
- #io ⇒ Object
- #lines ⇒ Object
Constructor Details
#initialize(command) ⇒ Pipe
Returns a new instance of Pipe.
5 6 7 |
# File 'lib/git_statistics/pipe.rb', line 5 def initialize(command) @command = command end |
Instance Method Details
#command ⇒ Object
9 10 11 |
# File 'lib/git_statistics/pipe.rb', line 9 def command @command.dup.gsub(/\A\|/i, '') end |
#each(&block) ⇒ Object
13 14 15 |
# File 'lib/git_statistics/pipe.rb', line 13 def each(&block) lines.each(&block) end |
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/git_statistics/pipe.rb', line 17 def empty? lines.empty? end |
#io ⇒ Object
25 26 27 |
# File 'lib/git_statistics/pipe.rb', line 25 def io open("|#{command} 2>/dev/null") end |
#lines ⇒ Object
21 22 23 |
# File 'lib/git_statistics/pipe.rb', line 21 def lines io.map { |line| line.strip.force_encoding('iso-8859-1').encode('utf-8') } end |