random_methods 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/random_methods.rb +101 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 96b640443e3ad7f22417789137ae1a7cd45b2c63
4
+ data.tar.gz: b9668977e6645af9c673bbfb4b143a6a6465a35a
5
+ SHA512:
6
+ metadata.gz: 1675729d071a3e21b57d128c956e2e2c5e1eeab58c857c175627568d246e65163e734db08568789a3678e21ba46ffe57a7d0e70ad1c5a72927dd9ae5f001f175
7
+ data.tar.gz: 52ac5f2d06ffcea1b4e04196f3b8d533dabea37a36743167fd3c18ced7980c07df368a7bf1611f31274ab3beb9839afa57ef6ace754a66a7647e104af0bdeae8
@@ -0,0 +1,101 @@
1
+ # Random methods and class modifiers to add to my own gem
2
+
3
+ #VITAL FOR LINK CLASS
4
+ # used for my webcrawling needs
5
+ @domainEnd = [/\com/, /\org/, /\net/, /\mil/] # for some reason, 'gov' does not word
6
+ @@Domains = Regexp.union(@domainEnd)
7
+
8
+ class Array
9
+ def puts_all
10
+ self.each do |item|
11
+ puts item
12
+ end
13
+ end
14
+ def print_all
15
+ self.each do |item|
16
+ print "#{item} "
17
+ end
18
+ end
19
+ def write_all(file)
20
+ somefile = open(file, 'a')
21
+ self.each do |item|
22
+ somefile.puts(item)
23
+ end
24
+ somefile.close
25
+ end
26
+
27
+ def alt_scan(item) # test array for a substring, if string contains substring return the string
28
+ self.each do |var|
29
+ begin
30
+ if var[item] then
31
+ return var
32
+ end
33
+ rescue
34
+ puts "Variable not found."
35
+ return nil
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ class String
43
+ def half
44
+ strL = self.length
45
+ strH = strL / 2
46
+ newString = self[0..strH]
47
+ return newString
48
+ end
49
+
50
+ def quarter
51
+ strL = self.length
52
+ strH = strL / 4
53
+ newString = self[0..strH]
54
+ return newString
55
+ end
56
+
57
+ def three_quarters
58
+ strL = self.length
59
+ strH = strL - (strL / 4)
60
+ newString = self[0..strH]
61
+ return newString
62
+ end
63
+
64
+ # made for link class
65
+ def index_domain # gives index of the domain ending
66
+ domainIndex = self.index(@@Domains)
67
+ if domainIndex == nil then
68
+ return nil
69
+ else
70
+ return domainIndex
71
+ end
72
+ end
73
+
74
+ def domain # returns all of the url before and including the domain ending
75
+ domainIndex = self.index(@@Domains)
76
+ if domainIndex == nil then
77
+ return nil
78
+ else
79
+ domainEnd = domainIndex + 2
80
+ domainName = self[0..domainEnd]
81
+ return domainName
82
+ end
83
+ end
84
+
85
+ end
86
+
87
+ class Link
88
+
89
+ def self.set(str)
90
+ @href = str
91
+ end
92
+
93
+ def self.get
94
+ return @href
95
+ end
96
+
97
+ def self.delete
98
+ @href = nil
99
+ end
100
+
101
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: random_methods
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chandler Lofland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Adds simple methods to Array and String classes, and also add its own
14
+ Link class for URLs.
15
+ email: chandlerl14@outlook.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/random_methods.rb
21
+ homepage:
22
+ licenses:
23
+ - MIT
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.4.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A simple gem for my repetetive tasks.
45
+ test_files: []