hevery 2019.10.30

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 +7 -0
  2. data/bin/every +52 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a12c431c84855e9d78873010eff00d8cd01b8a1
4
+ data.tar.gz: 0e71c5e4b86d283645f30127258a71b106bbbd83
5
+ SHA512:
6
+ metadata.gz: 629da6c920c1c688ac7a878f910f90a7b2cd265d31c83a12038679d5a0b4039eaf1b1ddca4bf1cb2a46f93630c3d9302322379ab6cacba7cf6b056f50937b658
7
+ data.tar.gz: ff9fd457bc814527ad18aa11ce08bbc80c2957868a3034da5d218f1db8972570113673996b9e78dcc02ea7d0184218b87dc1a464d730c75b4032fed52ef06981
data/bin/every ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # A script that will pretent to resize a number of images
4
+
5
+ require 'optparse'
6
+
7
+ # This hash will hold all of the options
8
+ # parsed from the command-line by
9
+ # OptionParser.
10
+
11
+ options = {}
12
+
13
+ optparse = OptionParser.new do |opts|
14
+ # Set a banner, displayed at the top
15
+ # of the help screen.
16
+ opts.banner = "Usage: every [options]"
17
+
18
+ # Define the options, and what they do
19
+
20
+ options[:lineNumber] = 1
21
+ opts.on( '-l', '--linenumber linenumber', Integer,'The number of the line to output' ) do |file|
22
+ options[:lineNumber] = file
23
+ end
24
+
25
+ options[:intervalNumber] = 2
26
+ opts.on( '-i', '--interval intervalnumber', Integer, 'The interval of the line numbers' ) do |file|
27
+ options[:intervalNumber] = file
28
+ end
29
+
30
+ # This displays the help screen, all programs are
31
+ # assumed to have this option.
32
+ opts.on( '-h', '--help', 'Display this screen' ) do
33
+ puts opts
34
+ exit
35
+ end
36
+ end
37
+
38
+ # Parse the command-line. Remember there are two forms
39
+ # of the parse mothod.The 'parse' method simply parses
40
+ # ARGV, while the 'parse!' method parses ARGV and removes
41
+ # any options found there, as well as any paremeters for
42
+ # the options. What's left is the list of files to resize.
43
+ optparse.parse!
44
+
45
+ $stdin.each do |line|
46
+ # puts $stdin.lineno.class
47
+ # puts options[:intervalNumber].class
48
+ # puts options[:lineNumber].class
49
+ if (($stdin.lineno % options[:intervalNumber]) == options[:lineNumber] ) #正是第这么多行。
50
+ puts line #输出。
51
+ end #if (($stdin.lineno % options[:intervalNumber]) == options[:lineNumber] ) #正是第这么多行。
52
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hevery
3
+ version: !ruby/object:Gem::Version
4
+ version: 2019.10.30
5
+ platform: ruby
6
+ authors:
7
+ - Hxcan Cai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Output the lth line of every n lines.
14
+ email: caihuosheng@gmail.com
15
+ executables:
16
+ - every
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/every
21
+ homepage: http://rubygems.org/gems/every
22
+ licenses:
23
+ - MPL-2.0
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.6.14.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Every.
45
+ test_files: []