hevery 2019.10.31 → 2019.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/every +5 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9c9d3a41f695e03edc088d57be72e0db45d02d2
4
- data.tar.gz: f38e4ab2ced478cedfcc9522cfd6fc9763099d4e
3
+ metadata.gz: 748302727b9d25fe311ad115d2d01d25fcf0eb20
4
+ data.tar.gz: 3cb0e28188a1e41c7eb4ab33285e1adc98ce4a7e
5
5
  SHA512:
6
- metadata.gz: 8b81f6b9d17a516134b6a2cadc2124a4c44a49997babccafb5643603840d7ffe1b7dd06d62df94e96f07712711dd54bdd43129b9a69a5f3b93c587827d91e8df
7
- data.tar.gz: 1ac61b916c869379fa70f52aaa808a26284e836d21b8a821cdfc1a259fa88c5035089d5184a81ea6336cd931190ef105bdcb0b1083efde3946413c596805cc8f
6
+ metadata.gz: 176467c3fd73ae4370424b6988fd35871dab50939147a962985910579264ce7e8b2e4e950c47cf3af79daa53dec4821d01d163495bc78d6411d527256e6bb65e
7
+ data.tar.gz: c9228f6107a3b9448d5d1dfdea23a21fec983fa0c997d3e737237b887fa481f813ce9f8475845f28a8aae4e612d4dfe39f01c60f460c9b0e1740b62611b78a19
data/bin/every CHANGED
@@ -4,10 +4,6 @@
4
4
 
5
5
  require 'optparse'
6
6
 
7
- # This hash will hold all of the options
8
- # parsed from the command-line by
9
- # OptionParser.
10
-
11
7
  Signal.trap("PIPE", "EXIT")
12
8
 
13
9
  options = {}
@@ -26,7 +22,9 @@ optparse = OptionParser.new do |opts|
26
22
 
27
23
  options[:intervalNumber] = 2
28
24
  opts.on( '-i', '--interval intervalnumber', Integer, 'The interval of the line numbers' ) do |file|
29
- options[:intervalNumber] = file
25
+ if (file > 1) #必须大于1.
26
+ options[:intervalNumber] = file
27
+ end #if (file > 1) #必须大于1.
30
28
  end
31
29
 
32
30
  # This displays the help screen, all programs are
@@ -37,17 +35,11 @@ optparse = OptionParser.new do |opts|
37
35
  end
38
36
  end
39
37
 
40
- # Parse the command-line. Remember there are two forms
41
- # of the parse mothod.The 'parse' method simply parses
42
- # ARGV, while the 'parse!' method parses ARGV and removes
43
- # any options found there, as well as any paremeters for
44
- # the options. What's left is the list of files to resize.
45
38
  optparse.parse!
46
39
 
40
+ options[:lineNumber] = options[:lineNumber] % options[:intervalNumber] #兼容行号大于等于周期的情况。
41
+
47
42
  $stdin.each do |line|
48
- # puts $stdin.lineno.class
49
- # puts options[:intervalNumber].class
50
- # puts options[:lineNumber].class
51
43
  if (($stdin.lineno % options[:intervalNumber]) == options[:lineNumber] ) #正是第这么多行。
52
44
  puts line #输出。
53
45
  end #if (($stdin.lineno % options[:intervalNumber]) == options[:lineNumber] ) #正是第这么多行。
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hevery
3
3
  version: !ruby/object:Gem::Version
4
- version: 2019.10.31
4
+ version: 2019.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hxcan Cai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2019-11-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Output the lth line of every n lines.
14
14
  email: caihuosheng@gmail.com