corelib 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c0ac87a91fb82f694988f255c4be34ef9c573435
4
- data.tar.gz: e455b0b884bdea156b1546bcf651b7f91d540c50
2
+ SHA256:
3
+ metadata.gz: ce4b836fee0895f69d0a5b668c9a7d4d013786fa1c399aa75c0450bf7fdf4430
4
+ data.tar.gz: 90d34235062500ac7364b0157cb32f711142f47653deea3dc11161afef39419c
5
5
  SHA512:
6
- metadata.gz: cadb1a59d488749bbf0a67614262556374489506788a49e3a2cd0687c84521904ec3180aa5769c6c36514eff337ebc94fa7918e64e092449cdef4b35c9330f22
7
- data.tar.gz: 90f8e2a12a538c73ad8006ffc3fd0971e9952806dabab9362fde193f57ec3d095f99ca89ea81ad161847456829ecd3b768d96817e38a201f108b77e0b5c77a8f
6
+ metadata.gz: 72eeb89b7302820e1ff7ad6c9c8610c5a0060d86161016e76cdf01af207a52fa37d77781a717433f55b076d3c5a021c97f05834c1cbc4a55a8bf55ecf2a88d76
7
+ data.tar.gz: e16032fd85154aa7484b72060b8dfeb50b59b9cb710bc85fb5fc05937ab3acc5ec510180385a2050224c7e6e32ed9e8524507c4e497b9dced6a97949723a6390
@@ -1,10 +1,10 @@
1
- class Array
2
-
3
- alias_method :append, :<<
4
- alias_method :prepend, :unshift
5
- alias_method :remove, :delete
6
- alias_method :remove_at, :delete_at
7
- alias_method :remove_last, :pop
8
- alias_method :add, :push
9
-
1
+ class Array
2
+
3
+ alias_method :append, :<<
4
+ alias_method :prepend, :unshift
5
+ alias_method :remove, :delete
6
+ alias_method :remove_at, :delete_at
7
+ alias_method :remove_last, :pop
8
+ alias_method :add, :push
9
+
10
10
  end
@@ -1,39 +1,39 @@
1
- class Array
2
-
3
- def extract_options!
4
- last.is_a?(::Hash) ? pop : {}
5
- end
6
-
7
- def to_yes_no(options={})
8
- self.collect {|e| e.to_yes_no(options)}
9
- end
10
-
11
- def add_blank_option(options={})
12
- doit = options.fetch(:doit, true)
13
- value = options.fetch(:value, 0)
14
- label = options.fetch(:label, "")
15
- self.insert(0, [label, value]) if doit
16
- self
17
- end
18
-
19
- #This method iterates over the Array as normal #each method. For each iteration
20
- #set two variables in the block, |item, flag|. item will be set tot he current item
21
- #in the iteration; flag will be set to "false" on all iterations except the last iteration
22
- def each_with_end_flag
23
- my_size = self.size
24
- self.each_with_index do |item, index|
25
- index + 1 == my_size ? yield(item, true) : yield(item, false)
26
- end
27
- end
28
-
29
- def not_empty?
30
- !self.empty?
31
- end
32
-
33
- def add_all(arr, options={})
34
- flatten = options.fetch(:flatten, true)
35
- a = flatten ? arr.flatten : arr
36
- self.concat(a)
37
- end
38
-
1
+ class Array
2
+
3
+ def extract_options!
4
+ last.is_a?(::Hash) ? pop : {}
5
+ end
6
+
7
+ def to_yes_no(options={})
8
+ self.collect {|e| e.to_yes_no(options)}
9
+ end
10
+
11
+ def add_blank_option(options={})
12
+ doit = options.fetch(:doit, true)
13
+ value = options.fetch(:value, 0)
14
+ label = options.fetch(:label, "")
15
+ self.insert(0, [label, value]) if doit
16
+ self
17
+ end
18
+
19
+ #This method iterates over the Array as normal #each method. For each iteration
20
+ #set two variables in the block, |item, flag|. item will be set tot he current item
21
+ #in the iteration; flag will be set to "false" on all iterations except the last iteration
22
+ def each_with_end_flag
23
+ my_size = self.size
24
+ self.each_with_index do |item, index|
25
+ index + 1 == my_size ? yield(item, true) : yield(item, false)
26
+ end
27
+ end
28
+
29
+ def not_empty?
30
+ !self.empty?
31
+ end
32
+
33
+ def add_all(arr, options={})
34
+ flatten = options.fetch(:flatten, true)
35
+ a = flatten ? arr.flatten : arr
36
+ self.concat(a)
37
+ end
38
+
39
39
  end
@@ -1,112 +1,112 @@
1
- class Array
2
-
3
- def options_label_for(value)
4
- sub = self.find {|each| each[1] == value}
5
- sub.nil? ? nil : sub[0]
6
- end
7
-
8
- def self.time_clock_type_options(options={})
9
- exemplify = options.fetch(:exemplify, true)
10
- id = options.fetch(:start_id, 1)
11
- return [["12-Hour Clock", id], ["24-Hour Clock", id+1]] if !exemplify
12
-
13
- t = Time.now
14
- s = options.fetch(:separater, " - ")
15
- h = options.fetch(:day, t.strftime("%l"))
16
- m = options.fetch(:month, t.strftime("%m"))
17
- ap =options.fetch(:am_pm, t.strftime("%P"))
18
- hm = options.fetch(:day24, t.strftime("%H"))
19
- [["12-Hour Clock#{s}(#{h}:#{m}#{ap})", id], ["24-Hour Clock#{s}(#{hm}:#{m})", id+1]]
20
- end
21
-
22
- def self.date_format_options(options={})
23
- exemplify = options.fetch(:exemplify, true)
24
- exemplify ? date_format_options_exemplified_raw(options) : date_format_options_raw(options)
25
- end
26
-
27
- def self.date_format_options_raw(options={})
28
- id = options.fetch(:start_id, 1)
29
- [["MM/DD/YYYY", id], ["MM-DD-YYYY", id+1], ["DD/MM/YYYY", id+2], ["DD-MM-YYYY", id+3], ["YYYY/MM/DD", id+4], ["YYYY-MM-DD", id+5], ["DD.MM.YYYY", id+6], ["YYYY.MM.DD", id+7]]
30
- end
31
-
32
- def self.date_format_options_exemplified_raw(options={})
33
- id = options.fetch(:start_id, 1)
34
- t = Time.now
35
- s = options.fetch(:separater, " - ")
36
- d = options.fetch(:day, t.strftime("%d"))
37
- m = options.fetch(:month, t.strftime("%m"))
38
- y = options.fetch(:year, t.year)
39
- [["MM/DD/YYYY#{s}(#{m}/#{d}/#{y})", id], ["MM-DD-YYYY#{s}(#{m}-#{d}-#{y})", id+1], ["DD/MM/YYYY#{s}(#{d}/#{m}/#{y})", id+2], ["DD-MM-YYYY#{s}(#{d}-#{m}-#{y})", id+3],
40
- ["YYYY/MM/DD#{s}(#{y}/#{m}/#{d})", id+4], ["YYYY-MM-DD#{s}(#{y}-#{m}-#{d})", id+5], ["DD.MM.YYYY#{s}(#{d}.#{m}.#{y})", id+6], ["YYYY.MM.DD#{s}(#{y}.#{m}.#{d})", id+7]]
41
- end
42
-
43
- def self.month_options(options={})
44
- abbrev = options.fetch(:abbrev, false)
45
- list = abbrev ? month_options_abbrev_raw : month_options_raw
46
- list.format_options_list(options)
47
- end
48
-
49
- def self.month_options_raw(start=1)
50
- [["January", start], ["February", start + 1], ["March", start + 2], ["April", start + 3], ["May", start + 4], ["June", start + 5],
51
- ["July", start + 6], ["August", start + 7], ["September", start + 8], ["October", start + 9], ["November", start + 10], ["December", start + 11]]
52
- end
53
-
54
- def self.month_options_abbrev_raw(start=1)
55
- [["Jan", start], ["Feb", start + 1], ["Mar", start + 2], ["Apr", start + 3], ["May", start + 4], ["Jun", start + 5],
56
- ["Jul", start + 6], ["Aug", start + 7], ["Sep", start + 8], ["Oct", start + 9], ["Nov", start + 10], ["Dec", start + 11]]
57
- end
58
-
59
- def self.us_state_options(options={})
60
- abbrev = options.fetch(:abbrev, false)
61
- list = abbrev ? us_state_options_abbrev_raw : us_state_options_raw
62
- list.format_options_list(options)
63
- end
64
-
65
- def self.us_state_options_raw
66
- [['Alabama', 'AL'], ['Alaska', 'AK'], ['Arizona', 'AZ'], ['Arkansas', 'AR'], ['California', 'CA'], ['Colorado', 'CO'],
67
- ['Connecticut', 'CT'], ['D.C.', 'DC'], ['Delaware', 'DE'], ['Florida', 'FL'], ['Georgia', 'GA'], ['Hawaii', 'HI'], ['Idaho', 'ID'],
68
- ['Illinois', 'IL'], ['Indiana', 'IN'], ['Iowa', 'IA'], ['Kansas', 'KS'], ['Kentucky', 'KY'], ['Louisiana', 'LA'],
69
- ['Maine', 'ME'], ['Maryland', 'MD'], ['Massachusetts', 'MA'], ['Michigan', 'MI'], ['Minnesota', 'MN'], ['Mississippi', 'MS'],
70
- ['Missouri', 'MO'], ['Montana', 'MT'], ['Nebraska', 'NE'], ['Nevada', 'NV'], ['New Hampshire', 'NH'], ['New Jersey', 'NJ'],
71
- ['New Mexico', 'NM'], ['New York', 'NY'], ['North Carolina', 'NC'], ['North Dakota', 'ND'], ['Ohio', 'OH'], ['Oklahoma', 'OK'],
72
- ['Oregon', 'OR'], ['Pennsylvania', 'PA'], ['Rhode Island', 'RI'], ['South Carolina', 'SC'], ['South Dakota', 'SD'],
73
- ['Tennessee', 'TN'], ['Texas', 'TX'], ['Utah', 'UT'], ['Vermont', 'VT'], ['Virginia', 'VA'], ['Washington', 'WA'],
74
- ['West Virginia', 'WV'], ['Wisconsin', 'WI'], ['Wyoming', 'WY']]
75
- end
76
-
77
- def self.us_state_options_abbrev_raw
78
- [['AL', 'AL'], ['AK', 'AK'], ['AZ', 'AZ'], ['AR', 'AR'], ['CA', 'CA'], ['CO', 'CO'],
79
- ['CT', 'CT'], ['DC', 'DC'], ['DE', 'DE'], ['FL', 'FL'], ['GA', 'GA'], ['HI', 'HI'], ['ID', 'ID'],
80
- ['IL', 'IL'], ['IN', 'IN'], ['IA', 'IA'], ['KS', 'KS'], ['KY', 'KY'], ['LA', 'LA'],
81
- ['ME', 'ME'], ['MD', 'MD'], ['MA', 'MA'], ['MI', 'MI'], ['MN', 'MN'], ['MS', 'MS'],
82
- ['MO', 'MO'], ['MT', 'MT'], ['NE', 'NE'], ['NV', 'NV'], ['NH', 'NH'], ['NJ', 'NJ'],
83
- ['NM', 'NM'], ['NY', 'NY'], ['NC', 'NC'], ['ND', 'ND'], ['OH', 'OH'], ['OK', 'OK'],
84
- ['OR', 'OR'], ['PA', 'PA'], ['RI', 'RI'], ['SC', 'SC'], ['SD', 'SD'],
85
- ['TN', 'TN'], ['TX', 'TX'], ['UT', 'UT'], ['VT', 'VT'], ['VA', 'VA'], ['WA', 'WA'],
86
- ['WV', 'WV'], ['WI', 'WI'], ['WY', 'WY'],]
87
- end
88
-
89
- def format_options_list(options={})
90
- insert_options_label_blank(options)
91
- change_options_label_case(options) if options[:format] #Change case if :format is set, otherwise use default case
92
- self
93
- end
94
-
95
- private
96
-
97
- def insert_options_label_blank(options)
98
- add_blank = options.fetch(:blank, "true")
99
- blank_value = options.fetch(:blank_value, 0)
100
- blank_label = options.fetch(:blank_label, "")
101
- blank_position = options.fetch(:blank_position, 0)
102
- self.insert(blank_position, [blank_label, blank_value]) if add_blank
103
- end
104
-
105
- def change_options_label_case(options)
106
- label_format = options.fetch(:format)
107
- self.each {|opt| opt[0].upcase!} if label_format == "Up"
108
- self.each {|opt| opt[0].capitalize!} if label_format == "Cap"
109
- self.each {|opt| opt[0].downcase!} if label_format == "Down"
110
- end
111
-
112
- end
1
+ class Array
2
+
3
+ def options_label_for(value)
4
+ sub = self.find {|each| each[1] == value}
5
+ sub.nil? ? nil : sub[0]
6
+ end
7
+
8
+ def self.time_clock_type_options(options={})
9
+ exemplify = options.fetch(:exemplify, true)
10
+ id = options.fetch(:start_id, 1)
11
+ return [["12-Hour Clock", id], ["24-Hour Clock", id+1]] if !exemplify
12
+
13
+ t = Time.now
14
+ s = options.fetch(:separater, " - ")
15
+ h = options.fetch(:day, t.strftime("%l"))
16
+ m = options.fetch(:month, t.strftime("%m"))
17
+ ap =options.fetch(:am_pm, t.strftime("%P"))
18
+ hm = options.fetch(:day24, t.strftime("%H"))
19
+ [["12-Hour Clock#{s}(#{h}:#{m}#{ap})", id], ["24-Hour Clock#{s}(#{hm}:#{m})", id+1]]
20
+ end
21
+
22
+ def self.date_format_options(options={})
23
+ exemplify = options.fetch(:exemplify, true)
24
+ exemplify ? date_format_options_exemplified_raw(options) : date_format_options_raw(options)
25
+ end
26
+
27
+ def self.date_format_options_raw(options={})
28
+ id = options.fetch(:start_id, 1)
29
+ [["MM/DD/YYYY", id], ["MM-DD-YYYY", id+1], ["DD/MM/YYYY", id+2], ["DD-MM-YYYY", id+3], ["YYYY/MM/DD", id+4], ["YYYY-MM-DD", id+5], ["DD.MM.YYYY", id+6], ["YYYY.MM.DD", id+7]]
30
+ end
31
+
32
+ def self.date_format_options_exemplified_raw(options={})
33
+ id = options.fetch(:start_id, 1)
34
+ t = Time.now
35
+ s = options.fetch(:separater, " - ")
36
+ d = options.fetch(:day, t.strftime("%d"))
37
+ m = options.fetch(:month, t.strftime("%m"))
38
+ y = options.fetch(:year, t.year)
39
+ [["MM/DD/YYYY#{s}(#{m}/#{d}/#{y})", id], ["MM-DD-YYYY#{s}(#{m}-#{d}-#{y})", id+1], ["DD/MM/YYYY#{s}(#{d}/#{m}/#{y})", id+2], ["DD-MM-YYYY#{s}(#{d}-#{m}-#{y})", id+3],
40
+ ["YYYY/MM/DD#{s}(#{y}/#{m}/#{d})", id+4], ["YYYY-MM-DD#{s}(#{y}-#{m}-#{d})", id+5], ["DD.MM.YYYY#{s}(#{d}.#{m}.#{y})", id+6], ["YYYY.MM.DD#{s}(#{y}.#{m}.#{d})", id+7]]
41
+ end
42
+
43
+ def self.month_options(options={})
44
+ abbrev = options.fetch(:abbrev, false)
45
+ list = abbrev ? month_options_abbrev_raw : month_options_raw
46
+ list.format_options_list(options)
47
+ end
48
+
49
+ def self.month_options_raw(start=1)
50
+ [["January", start], ["February", start + 1], ["March", start + 2], ["April", start + 3], ["May", start + 4], ["June", start + 5],
51
+ ["July", start + 6], ["August", start + 7], ["September", start + 8], ["October", start + 9], ["November", start + 10], ["December", start + 11]]
52
+ end
53
+
54
+ def self.month_options_abbrev_raw(start=1)
55
+ [["Jan", start], ["Feb", start + 1], ["Mar", start + 2], ["Apr", start + 3], ["May", start + 4], ["Jun", start + 5],
56
+ ["Jul", start + 6], ["Aug", start + 7], ["Sep", start + 8], ["Oct", start + 9], ["Nov", start + 10], ["Dec", start + 11]]
57
+ end
58
+
59
+ def self.us_state_options(options={})
60
+ abbrev = options.fetch(:abbrev, false)
61
+ list = abbrev ? us_state_options_abbrev_raw : us_state_options_raw
62
+ list.format_options_list(options)
63
+ end
64
+
65
+ def self.us_state_options_raw
66
+ [['Alabama', 'AL'], ['Alaska', 'AK'], ['Arizona', 'AZ'], ['Arkansas', 'AR'], ['California', 'CA'], ['Colorado', 'CO'],
67
+ ['Connecticut', 'CT'], ['D.C.', 'DC'], ['Delaware', 'DE'], ['Florida', 'FL'], ['Georgia', 'GA'], ['Hawaii', 'HI'], ['Idaho', 'ID'],
68
+ ['Illinois', 'IL'], ['Indiana', 'IN'], ['Iowa', 'IA'], ['Kansas', 'KS'], ['Kentucky', 'KY'], ['Louisiana', 'LA'],
69
+ ['Maine', 'ME'], ['Maryland', 'MD'], ['Massachusetts', 'MA'], ['Michigan', 'MI'], ['Minnesota', 'MN'], ['Mississippi', 'MS'],
70
+ ['Missouri', 'MO'], ['Montana', 'MT'], ['Nebraska', 'NE'], ['Nevada', 'NV'], ['New Hampshire', 'NH'], ['New Jersey', 'NJ'],
71
+ ['New Mexico', 'NM'], ['New York', 'NY'], ['North Carolina', 'NC'], ['North Dakota', 'ND'], ['Ohio', 'OH'], ['Oklahoma', 'OK'],
72
+ ['Oregon', 'OR'], ['Pennsylvania', 'PA'], ['Rhode Island', 'RI'], ['South Carolina', 'SC'], ['South Dakota', 'SD'],
73
+ ['Tennessee', 'TN'], ['Texas', 'TX'], ['Utah', 'UT'], ['Vermont', 'VT'], ['Virginia', 'VA'], ['Washington', 'WA'],
74
+ ['West Virginia', 'WV'], ['Wisconsin', 'WI'], ['Wyoming', 'WY']]
75
+ end
76
+
77
+ def self.us_state_options_abbrev_raw
78
+ [['AL', 'AL'], ['AK', 'AK'], ['AZ', 'AZ'], ['AR', 'AR'], ['CA', 'CA'], ['CO', 'CO'],
79
+ ['CT', 'CT'], ['DC', 'DC'], ['DE', 'DE'], ['FL', 'FL'], ['GA', 'GA'], ['HI', 'HI'], ['ID', 'ID'],
80
+ ['IL', 'IL'], ['IN', 'IN'], ['IA', 'IA'], ['KS', 'KS'], ['KY', 'KY'], ['LA', 'LA'],
81
+ ['ME', 'ME'], ['MD', 'MD'], ['MA', 'MA'], ['MI', 'MI'], ['MN', 'MN'], ['MS', 'MS'],
82
+ ['MO', 'MO'], ['MT', 'MT'], ['NE', 'NE'], ['NV', 'NV'], ['NH', 'NH'], ['NJ', 'NJ'],
83
+ ['NM', 'NM'], ['NY', 'NY'], ['NC', 'NC'], ['ND', 'ND'], ['OH', 'OH'], ['OK', 'OK'],
84
+ ['OR', 'OR'], ['PA', 'PA'], ['RI', 'RI'], ['SC', 'SC'], ['SD', 'SD'],
85
+ ['TN', 'TN'], ['TX', 'TX'], ['UT', 'UT'], ['VT', 'VT'], ['VA', 'VA'], ['WA', 'WA'],
86
+ ['WV', 'WV'], ['WI', 'WI'], ['WY', 'WY'],]
87
+ end
88
+
89
+ def format_options_list(options={})
90
+ insert_options_label_blank(options)
91
+ change_options_label_case(options) if options[:format] #Change case if :format is set, otherwise use default case
92
+ self
93
+ end
94
+
95
+ private
96
+
97
+ def insert_options_label_blank(options)
98
+ add_blank = options.fetch(:blank, "true")
99
+ blank_value = options.fetch(:blank_value, 0)
100
+ blank_label = options.fetch(:blank_label, "")
101
+ blank_position = options.fetch(:blank_position, 0)
102
+ self.insert(blank_position, [blank_label, blank_value]) if add_blank
103
+ end
104
+
105
+ def change_options_label_case(options)
106
+ label_format = options.fetch(:format)
107
+ self.each {|opt| opt[0].upcase!} if label_format == "Up"
108
+ self.each {|opt| opt[0].capitalize!} if label_format == "Cap"
109
+ self.each {|opt| opt[0].downcase!} if label_format == "Down"
110
+ end
111
+
112
+ end
@@ -1,27 +1,27 @@
1
- # options = {:key1 => 'default'}.merge(options)
2
-
3
- class Array
4
-
5
- def sum (options = {})
6
- strict = options.fetch(:strict, true)
7
- strict ? sum_strict : sum_loose
8
- end
9
-
10
- private
11
-
12
- def sum_strict
13
- total = 0
14
- self.each {|item| total = total + item }
15
- total
16
- end
17
-
18
- def sum_loose
19
- total = 0
20
- self.each do |item|
21
- val = item.is_a?(Numeric) ? item : 0
22
- total = total + val
23
- end
24
- total
25
- end
26
-
1
+ # options = {:key1 => 'default'}.merge(options)
2
+
3
+ class Array
4
+
5
+ def sum (options = {})
6
+ strict = options.fetch(:strict, true)
7
+ strict ? sum_strict : sum_loose
8
+ end
9
+
10
+ private
11
+
12
+ def sum_strict
13
+ total = 0
14
+ self.each {|item| total = total + item }
15
+ total
16
+ end
17
+
18
+ def sum_loose
19
+ total = 0
20
+ self.each do |item|
21
+ val = item.is_a?(Numeric) ? item : 0
22
+ total = total + val
23
+ end
24
+ total
25
+ end
26
+
27
27
  end
@@ -1,17 +1,17 @@
1
- class FalseClass
2
-
3
- #Cap, Down, Up
4
- def to_yes_no(options={})
5
- value = options.fetch(:if_no, "No")
6
- FalseClass.format_to_yes_no(value, options)
7
- end
8
-
9
- def self.format_to_yes_no(value, options)
10
- return value if !options.has_key?(:format) #If format is unspecified, use the default
11
- format = options[:format]
12
- return value.upcase if format == "Up"
13
- return value.downcase if format == "Down"
14
- value.capitalize #format has to be capital at this point (or an invalid format, so we will assume capital)
15
- end
16
-
1
+ class FalseClass
2
+
3
+ #Cap, Down, Up
4
+ def to_yes_no(options={})
5
+ value = options.fetch(:if_no, "No")
6
+ FalseClass.format_to_yes_no(value, options)
7
+ end
8
+
9
+ def self.format_to_yes_no(value, options)
10
+ return value if !options.has_key?(:format) #If format is unspecified, use the default
11
+ format = options[:format]
12
+ return value.upcase if format == "Up"
13
+ return value.downcase if format == "Down"
14
+ value.capitalize #format has to be capital at this point (or an invalid format, so we will assume capital)
15
+ end
16
+
17
17
  end
@@ -1,9 +1,9 @@
1
- class TrueClass
2
-
3
- #format accepts (C-Capitalized, U-Uppercase, L-Lowercase)
4
- def to_yes_no(options={})
5
- value = options.fetch(:if_yes, "Yes")
6
- FalseClass.format_to_yes_no(value, options)
7
- end
8
-
1
+ class TrueClass
2
+
3
+ #format accepts (C-Capitalized, U-Uppercase, L-Lowercase)
4
+ def to_yes_no(options={})
5
+ value = options.fetch(:if_yes, "Yes")
6
+ FalseClass.format_to_yes_no(value, options)
7
+ end
8
+
9
9
  end
@@ -1,17 +1,17 @@
1
- class Hash
2
-
3
- def not_empty?
4
- !self.empty?
5
- end
6
-
7
- #This method iterates over the Array as normal #each method. For each iteration
8
- #set two variables in the block, |item, flag|. item will be set tot he current item
9
- #in the iteration; flag will be set to "false" on all iterations except the last iteration
10
- def each_with_end_flag
11
- my_size = self.size
12
- self.each_with_index do |item, index|
13
- index + 1 == my_size ? yield(item, true) : yield(item, false)
14
- end
15
- end
16
-
1
+ class Hash
2
+
3
+ def not_empty?
4
+ !self.empty?
5
+ end
6
+
7
+ #This method iterates over the Array as normal #each method. For each iteration
8
+ #set two variables in the block, |item, flag|. item will be set tot he current item
9
+ #in the iteration; flag will be set to "false" on all iterations except the last iteration
10
+ def each_with_end_flag
11
+ my_size = self.size
12
+ self.each_with_index do |item, index|
13
+ index + 1 == my_size ? yield(item, true) : yield(item, false)
14
+ end
15
+ end
16
+
17
17
  end