Class: Header
Direct Known Subclasses
Bullet
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Classifide
#address?, #children, #city?, #date?, #email?, #institution?, #many_words?, #more_words_than?, #name?, #phone?, #profession?, #section?, #set_new_value, #type?, #verbs?
Constructor Details
#initialize(classifide) ⇒ Header
Returns a new instance of Header.
5
6
7
8
9
|
# File 'lib/classes/header.rb', line 5
def initialize(classifide)
both_classifications.each do |classification|
instance_variable_set(("@" + classification).to_sym, classifide.send(classification))
end
end
|
Instance Attribute Details
#clean_profession ⇒ Object
Returns the value of attribute clean_profession.
3
4
5
|
# File 'lib/classes/header.rb', line 3
def clean_profession
@clean_profession
end
|
Instance Method Details
#convert_month_to_number(month) ⇒ Object
147
148
149
150
151
152
153
154
155
|
# File 'lib/classes/header.rb', line 147
def convert_month_to_number(month)
if season?
@converted_month = convert_season_to_number(month)
else
@converted_month = Date::ABBR_MONTHNAMES.index(month[0..2])
end
@converted_month_of_12 = (@converted_month / 12).to_f
end
|
#convert_season_to_number(season) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/classes/header.rb', line 133
def convert_season_to_number(season)
case season.downcase
when "winter"
0
when "spring"
3
when "summer"
6
when "fall"
9
end
end
|
#current? ⇒ Boolean
73
74
75
76
|
# File 'lib/classes/header.rb', line 73
def current?
!end_time_text?[regex_current].nil?
end
|
#duration ⇒ Object
125
126
127
128
129
130
131
|
# File 'lib/classes/header.rb', line 125
def duration
if season?
@duration = 3/12
else
@duration = end_time_number - start_time_number
end
end
|
#end_date_exists? ⇒ Boolean
90
91
92
|
# File 'lib/classes/header.rb', line 90
def end_date_exists?
split_date.length == 2
end
|
#end_month ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/classes/header.rb', line 113
def end_month
if @end_month.nil?
@end_month = split_date[1][regex_month]
if @end_month.nil?
@end_month = "Jan"
end
@end_month
else
@end_month
end
end
|
#end_time_number ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/classes/header.rb', line 78
def end_time_number
if date?
if end_date_exists?
if current?
@end_time_number = Date.today.strftime("%Y").to_i + (Date.today.strftime("%m")).to_i/12
else
@end_time_number = end_year.to_i + convert_month_to_number(end_month)
end
end
end
end
|
#end_time_text? ⇒ Boolean
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/classes/header.rb', line 61
def end_time_text?
if @end_time_text.nil?
if date?
if end_date_exists?
@end_time_text = split_date[1]
end
end
else
@end_time_text
end
end
|
#end_year ⇒ Object
109
110
111
|
# File 'lib/classes/header.rb', line 109
def end_year
@end_year = split_date[1][regex_year]
end
|
#get_professions ⇒ Object
24
25
26
|
# File 'lib/classes/header.rb', line 24
def get_professions
@clean_profession.gsub!(regex_companies, "")
end
|
#just_city ⇒ Object
161
162
163
164
|
# File 'lib/classes/header.rb', line 161
def just_city
split_cities[0]
end
|
#just_state ⇒ Object
166
167
168
|
# File 'lib/classes/header.rb', line 166
def just_state
split_cities[1]
end
|
#remove_all_but_profession ⇒ Object
28
29
30
|
# File 'lib/classes/header.rb', line 28
def remove_all_but_profession
@clean_profession = @clean_profession[regex_professions]
end
|
#remove_city ⇒ Object
15
16
17
|
# File 'lib/classes/header.rb', line 15
def remove_city
@clean_profession.gsub!(regex_cities, "")
end
|
#remove_date ⇒ Object
11
12
13
|
# File 'lib/classes/header.rb', line 11
def remove_date
@clean_profession = @text.gsub(regex_dates, "")
end
|
#remove_institution ⇒ Object
19
20
21
22
|
# File 'lib/classes/header.rb', line 19
def remove_institution
@clean_profession.gsub!(regex_companies, "")
@clean_profession.gsub!(regex_schools, "")
end
|
#season? ⇒ Boolean
33
34
35
|
# File 'lib/classes/header.rb', line 33
def season?
!@text[regex_season].nil?
end
|
#split_cities ⇒ Object
157
158
159
|
# File 'lib/classes/header.rb', line 157
def split_cities
@location = @cities.split(", ")
end
|
#split_date ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/classes/header.rb', line 37
def split_date
@prepare_split_date = @dates.gsub(Regexp.new('( |)(to\\b|-|–)( |)', 'i'), "{+)")
@split_date = @prepare_split_date.split("{+)")
if @split_date.kind_of?(Array)
@split_date
else
@split_date = [@dates]
end
end
|
#start_month ⇒ Object
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/classes/header.rb', line 98
def start_month
@start_month = split_date[0][regex_month]
if @start_month.nil?
@start_month = split_date[0][regex_season]
if @start_month.nil?
@start_month = "Jan"
end
end
@start_month
end
|
#start_time_number ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/classes/header.rb', line 53
def start_time_number
if date?
@start_time_number = start_year.to_i + convert_month_to_number(start_month)
else
nil
end
end
|
#start_time_text? ⇒ Boolean
47
48
49
50
51
|
# File 'lib/classes/header.rb', line 47
def start_time_text?
if date?
split_date[0]
end
end
|
#start_year ⇒ Object
94
95
96
|
# File 'lib/classes/header.rb', line 94
def start_year
@start_year = split_date[0][regex_year]
end
|