Class: WeatherCard::Hourly

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
InstanceMethods
Defined in:
lib/weathercard.rb

Constant Summary collapse

@@all =
[]
@@length =
11
@@horizontal =
'-'.colorize(:light_yellow)
@@vertical =
'|'.colorize(:light_yellow)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

reset

Methods included from InstanceMethods

#initialize, #line_end, #line_intermediate, #return_spaces

Instance Attribute Details

#dayObject

> receives day object



253
254
255
# File 'lib/weathercard.rb', line 253

def day
  @day
end

Class Method Details

.allObject



274
275
276
# File 'lib/weathercard.rb', line 274

def self.all
    @@all
end

.displayObject



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/weathercard.rb', line 328

def self.display
    beginning = 0
    final = 5
    n = (self.length / 6.0 + 0.5).to_i
    n.times do
        row1 = ''
        row2 = ''
        row3 = ''
        row4 = ''
        row5 = ''
        row6 = ''
        row7 = ''
        row8 = ''
        self.all[beginning..final].each do |weather|
            row1 += weather.line1
            row2 += weather.line2
            row3 += weather.line3
            row4 += weather.line4
            row5 += weather.line5
            row6 += weather.line6
            row7 += weather.line7
            row8 += weather.line8
        end
        beginning += 6
        final += 6
        puts row1
        puts row2
        puts row3
        puts row4
        puts row5
        puts row6
        puts row7
        puts row8
    end
end

.horizontalObject



266
267
268
# File 'lib/weathercard.rb', line 266

def self.horizontal
    @@horizontal
end

.lengthObject



262
263
264
# File 'lib/weathercard.rb', line 262

def self.length
    @@length
end

.verticalObject



270
271
272
# File 'lib/weathercard.rb', line 270

def self.vertical
    @@vertical
end

Instance Method Details

#line1Object



278
279
280
# File 'lib/weathercard.rb', line 278

def line1
    line_end
end

#line2Object



282
283
284
285
286
287
# File 'lib/weathercard.rb', line 282

def line2
    str_length = day.day.length
    spaces = return_spaces(str_length)
    str = "#{day.day.colorize(:light_green)}#{spaces}"
    line_intermediate(str)
end

#line3Object



289
290
291
292
293
294
# File 'lib/weathercard.rb', line 289

def line3
    str_length = day.current_temp.length + 6
    spaces = return_spaces(str_length)
    str = "curr: #{day.current_temp}#{spaces}"
    line_intermediate(str)
end

#line4Object



296
297
298
299
300
301
# File 'lib/weathercard.rb', line 296

def line4
    str_length = day.feels_like.length + 7
    spaces = return_spaces(str_length)
    str = "feels: #{day.feels_like}#{spaces}"
    line_intermediate(str)
end

#line5Object



303
304
305
306
307
308
# File 'lib/weathercard.rb', line 303

def line5
    str_length = [day.short_detail.length, 11].min
    spaces = return_spaces(str_length)
    str = "#{day.short_detail[0..10]}#{spaces}"
    line_intermediate(str)
end

#line6Object



310
311
312
313
314
315
# File 'lib/weathercard.rb', line 310

def line6
    str_length = day.wind_magnitude.length
    spaces = return_spaces(str_length)
    str = "#{day.wind_magnitude}#{spaces}"
    line_intermediate(str)
end

#line7Object



317
318
319
320
321
322
# File 'lib/weathercard.rb', line 317

def line7
    str_length = day.humidity.length + day.precipitation.length + 4
    spaces = return_spaces(str_length)
    str = "h:#{day.humidity}#{spaces}p:#{day.precipitation}"
    line_intermediate(str)
end

#line8Object



324
325
326
# File 'lib/weathercard.rb', line 324

def line8
    line1
end